socket.core
===
This is a socket framework based on C # net standard2.0 write, can be used for .NET Framework / dotnet core assembly, can run in window (IOCP) / linux (epoll) .Use asynchronous connection, asynchronous send, asynchronous receive, Performance burst tables, and pass the stress test.
.NET Framework4.0 version https://github.com/fengma312/socket.framework
---
下面有中文文档
Install NuGet: https://www.nuget.org/packages/socket.core/
Package Manager: Install-Package socket.core
.Net CLI: dotnet add package socket.core
Paket CLI: paket add socket.core
One: TCP module introduction
Server socket.core.Server namespace, respectively, three modes push / pull / pack
Under the socket.core.
Client namespace of the client, there are three modes of push / pull / pack
The main process and the corresponding methods and events introduced.
Note: connectId (guid) represents a connection object, data (byte []), success (bool)
* 1. Initialize socket (corresponding to the three modes)
>Instantiate the server class TcpPushServer / TcpPullServer / TcpPackServer
>Instantiate the client class TcpPushClient / TcpPullClient / TcpPackClient
>Parameter introduction int numConnections maximum number of simultaneous connections, int receiveBufferSize buffer size (sink) for each socket I / O operation, int overtime timeout period in seconds (check every 10 seconds), When the value is 0, do not set the timeout, uint headerFlag Header tag range 0 ~ 1023 (0x3FF), when the header identifier is equal to 0, do not check the header
* 2. Start monitoring / connecting server
>Server server.Start (port);
>Client client.Connect (ip, port);
* 3. Trigger the connection event
>Server server.OnAccept (connectId); Received a connection id, can be used to send, receive, close the tag
>Client client.OnConnect(success); Receives whether to connect to the server successfully
* 4. Send a message
>Server server.Send (connectId, data, offset, length);
>Client client.Send (data, offset, length);
* 5. Trigger sent events
>Server server.OnSend (connectId, length);
>Client client.OnSend (length);
* 6. Triggered receive events
>Server server.OnReceive (connectId, data);
>Client client.OnReceive (data);
* 7. Close the connection
>Server server.Close (connectId);
>Client client.Close ();
* 8. Trigger to close the connection event
>Server server.OnClose (connectId);
>Client client.OnClose ();
Three models introduction
* One: push
>Will trigger the monitor event object OnReceive (connectId, data); the data immediately "pushed" to the application
* Two: pull
>OnReceive (connectId, length), which tells the application how much data has been received. The application checks the length of the data. If it meets, it calls the Fetch (connectId, length) method of the component, Data "pulled" out
* Three: pack
>pack The model component is a combination of the push and pull models. The application does not have to deal with subcontracts. The component guarantees that every application server.OnReceive (connectId, data) /client.OnReceive (data) event provides the application with a Complete data package
Note: The pack model component automatically adds a 4-byte (32-bit) header to each packet sent by the application. When the component receives the data, it is automatically packetized based on the header information. Each complete packet is sent to OnReceive The event is sent to the application
PACK header format(4 byte)4*8=32
XXXXXXXXXXYYYYYYYYYYYYYYYYYYYYYY
The first 10 X bits are the header identification bits, which are used for data packet verification. The effective header identification value ranges from 0 to 1023 (0x3FF). When the header identification equals 0, the header is not checked. The last 22 bits of Y are length bits. Package length. The maximum valid packet length can not exceed 4194303 (0x3FFFFF) bytes (bytes), the application can be set by the TcpPackServer / TcpPackClient constructor parameter headerFlag
Server other methods introduced
* 1. bool SetAttached(int connectId, object data)
> The server sets additional data for each client to prevent the user from establishing the user mapping table
* 2. T GetAttached<T>(int connectId)
> Get additional data for the specified client
* 3. Attributes:ConcurrentDictionary<int, string> ClientList
>Get the client information being connected <connectId, ip and port>
Two: UDP module introduction
* 1. Initialize the UDP implementation class UdpServer / UdpClients
>Server socket.core.Server.UdpServer
>Client socket.core.Client.UdpClients
>Parameters int receiveBufferSize Buffer size for each socket I / O operation (receiver)
* 2. Send data
>Server server.Send (remoteEndPoint, data, offset, length)
>Client client.Send (data, offset, length)
>Client client.Send(remoteEndPoint,data,offset,length)
* 3. Trigger sent events
>Server server.OnSend (remoteEndPoint, length)
>Client client.OnSend (length)
* 3. Trigger the receiving event
>Server server.OnReceive (remoteEndPoint, data, offset, length)
>Client client.OnReceive (data, offset, length)
2017/12/27
Technology is to share, we make progress together
socket.core
===
这是一个基于C# .net standard2.0 写的socket框架,可使用于.net Framework/dotnet core程序集,能在window(IOCP)/linux(epoll)运行.使用异步连接,异步发送,异步接收,性能爆表,并且通过压力测试。
---
安装NuGet: https://www.nuget.org/packages/socket.core/
Package Manager: Install-Package socket.core
.Net CLI :dotnet add package socket.core
Paket CLI:paket add socket.core
一:TCP模块介绍
服务端所在socket.core.Server命名空间下,分别为三种模式 push/pull/pack
客户端所在socket.core.Client命名空间下,分别为三种模式 push/pull/pack
主要流程与对应的方法和事件介绍.
注:connectId(int)代表着一个连接对象,data(byte[]),success(bool)
* 1.初始化TCP实现类(对应的三种模式)
>实例化服务端类 TcpPushServer/TcpPullServer/TcpPackServer
>实例化客户端类 TcpPushClient/TcpPullClient/TcpPackClient
>参数介绍int numConnections同时处理的最大连接数,int receiveBufferSize用于每个套接字I/O操作的缓冲区大小(接收端), int overtime超时时长,单位秒.(每10秒检查一次),当值为0时,不设置超时,uint headerFlag包头标记范围0~1023(0x3FF),当包头标识等于0时,不校验包头
* 2.启动监听/连接服务器
>服务端 server.Start(port);
>客户端 client.Connect(ip,port);
* 3.触发连接事件
>服务端 server.OnAccept(connectId); 接收到一个连接id,可用他来发送,接收,关闭的标记
>客户端 client.OnConnect(success); 接收是否成功连接到服务器
* 4.发送消息
>服务端 server.Send(connectId,data,offset,length);
>客户端 client.Send(data,offset,length);
* 5.触发已发送事件
>服务端 server.OnSend(connectId,length);
>客户端 client.OnSend(length);
* 6.触发接收事件
>服务端 server.OnReceive(connectId, data);
>客户端 client.OnReceive(data);
* 7.关闭连接
>服务端 server.Close(connectId);
>客户端 client.Close();
* 8.触发关闭连接事件
>服务端 server.OnClose(connectId);
>客户端 client.OnClose();
三种模型简介
* 一:push
>当接收到数据时会触发监听事件OnReceive(connectId,data);把数据立马“推”给应用程序
* 二:pull
>当接收到数据时会触发监听事件OnReceive(connectId,length),告诉应用程序当前已经接收到了多少数据长度,应用程序可使用GetLength(connectId)方法检查已接收的数据的长度,如果满足则调用组件的Fetch(connectId,length)方法,�
没有合适的资源?快使用搜索试试~ 我知道了~
能在linux(epoll)运行基于C# .net standard2.0 写的socket框架,可使用于dotnet core...
共116个文件
cs:47个
cache:29个
json:9个
需积分: 38 15 下载量 33 浏览量
2019-11-16
12:16:05
上传
评论
收藏 1.2MB ZIP 举报
温馨提示
能在linux(epoll)运行基于C# .net standard2.0 写的socket框架,可使用dotnet core程序集 安装NuGet: https://www.nuget.org/packages/socket.core/ Package Manager: Install-Package socket.core .Net CLI :dotnet add package socket.core Paket CLI:paket add socket.core 一:TCP模块介绍 服务端所在socket.core.Server命名空间下,分别为三种模式 push/pull/pack 客户端所在socket.core.Client命名空间下,分别为三种模式 push/pull/pack 主要流程与对应的方法和事件介绍. 注:connectId(int)代表着一个连接对象,data(byte[]),success(bool)
资源推荐
资源详情
资源评论
收起资源包目录
能在linux(epoll)运行基于C# .net standard2.0 写的socket框架,可使用于dotnet core程序集 (116个子文件)
test.linux.client.csprojAssemblyReference.cache 102KB
test.linux.server.csprojAssemblyReference.cache 102KB
test.linux.client.udp.csprojAssemblyReference.cache 95KB
test.linux.server.udp.csprojAssemblyReference.cache 95KB
socket.core.csprojAssemblyReference.cache 80KB
test.window.server.csprojAssemblyReference.cache 78KB
test.window.client.csprojAssemblyReference.cache 78KB
test.linux.client.assets.cache 30KB
test.linux.server.assets.cache 30KB
test.linux.client.udp.assets.cache 18KB
test.linux.server.udp.assets.cache 18KB
test.linux.client.csproj.nuget.cache 149B
test.linux.server.csproj.nuget.cache 149B
test.linux.client.udp.csproj.nuget.cache 149B
test.linux.server.udp.csproj.nuget.cache 149B
socket.core.csproj.nuget.cache 149B
socket.core.assets.cache 92B
test.linux.client.AssemblyInfoInputs.cache 42B
test.linux.client.csproj.CoreCompileInputs.cache 42B
test.linux.server.csproj.CoreCompileInputs.cache 42B
test.linux.server.AssemblyInfoInputs.cache 42B
test.linux.client.udp.AssemblyInfoInputs.cache 42B
test.linux.client.udp.csproj.CoreCompileInputs.cache 42B
test.linux.server.udp.AssemblyInfoInputs.cache 42B
test.linux.server.udp.csproj.CoreCompileInputs.cache 42B
test.window.server.csproj.CoreCompileInputs.cache 42B
test.window.client.csproj.CoreCompileInputs.cache 42B
socket.core.AssemblyInfoInputs.cache 42B
socket.core.csproj.CoreCompileInputs.cache 42B
App.config 1KB
App.config 449B
TcpServer.cs 20KB
TcpClients.cs 11KB
UdpClients.cs 9KB
UdpServer.cs 8KB
TcpPackServer.cs 8KB
TcpPullServer.cs 7KB
TcpPackClient.cs 6KB
TcpPushServer.cs 6KB
TcpPullClient.cs 5KB
TcpPushClient.cs 4KB
Program.cs 4KB
BufferManager.cs 3KB
Push.cs 3KB
Program.cs 2KB
NetWork.cs 2KB
Pack.cs 2KB
Pull.cs 2KB
Pack.cs 2KB
Pull.cs 2KB
Push.cs 2KB
SocketAsyncEventArgsPool.cs 2KB
socket.core.AssemblyInfo.cs 1KB
Push.cs 1KB
Program.cs 1KB
Pull.cs 1KB
Pull.cs 1KB
Pack.cs 1KB
Pack.cs 1KB
Push.cs 1KB
Program.cs 1KB
AssemblyInfo.cs 1KB
AssemblyInfo.cs 1KB
Program.cs 1KB
test.linux.client.udp.AssemblyInfo.cs 1KB
test.linux.server.udp.AssemblyInfo.cs 1KB
test.linux.client.AssemblyInfo.cs 1KB
test.linux.server.AssemblyInfo.cs 1KB
Program.cs 890B
SendingQueueItem.cs 803B
ConnectClient.cs 794B
WebSocketServer.cs 205B
TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs 0B
TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs 0B
TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs 0B
TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs 0B
TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs 0B
TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs 0B
test.window.server.csproj 3KB
test.window.client.csproj 3KB
socket.core.csproj 2KB
test.linux.client.csproj 920B
test.linux.server.csproj 718B
test.linux.client.udp.csproj 269B
test.linux.server.udp.csproj 269B
技术及用户手册——G-TcpClient Demo(Server Test Tool).doc 382KB
ServerTestTool.exe 391KB
G-TcpServerDemo.exe 307KB
.gitattributes 2KB
.gitignore 5KB
storage.ide 4KB
storage.ide-shm 32KB
storage.ide-wal 1.97MB
GTcpClt_Log.ini 107KB
project.assets.json 189KB
project.assets.json 189KB
project.assets.json 40KB
project.assets.json 40KB
project.assets.json 11KB
launch.json 1KB
共 116 条
- 1
- 2
资源评论
hardcom
- 粉丝: 1
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功