High performance, powerful, async TCP\UDP socket client\server.
Or Nuget console
Install-Package SToolkit.SocketNetwork
Including
using SToolkit.SocketNetwork;
Create server, TCP
SocketServer TcpServer = new SocketServer(NetworkType.Tcp, IPAddress.Loopback, 5400);
or UDP
SocketServer UdpServer = new SocketServer(NetworkType.Udp, IPAddress.Loopback, 5401);
Then bind events
- OnConnected - Called when new client connected
- OnDisconnected - Called when client disconnected
- OnReceived - Called when received data from client
- OnError - Called when server catch error
- OnStart - Called when server started
- OnStop - Called when server stoppped
Start server
TcpServer.Start();
UdpServer.Start();
All server functions
SocketServer(NetworkType type, IPAddress address, int port);
void Dispose();
void Start();
void Stop();
All server variables
string Uid;
IPAddress IPAddress;
int Port;
List<ClientConnection> ConnectedClients;
int LoopInterval;
int Backlog;
NetworkType ServerType;
bool UDPClientManage;
int UDPDataInterval;
Including
using SToolkit.SocketNetwork;
Create client, TCP
SocketClient TcpClient = new SocketClient(NetworkType.Tcp);
or UDP
SocketClient UdpClient = new SocketClient(NetworkType.Udp);
Bind events
- OnConnected - Called when client connected
- OnDisconnected - Called when client disconnected
- OnReceived - Called when received data from server
- OnError - Called when client catch error
Connect to remote server
TcpClient.Connect(IPAddress.Loopback, 5400);
UdpClient.Connect(IPAddress.Loopback, 5401);
All client functions
SocketClient(NetworkType type);
void Dispose();
void Connect(IPAddress address, int port);
void Connect(IPEndPoint point);
void Disconnect();
All client variables
NetworkType ClientType;
int LoopInterval;
int UDPDataInterval;