Skip to content

Latest commit

 

History

History
46 lines (32 loc) · 1.44 KB

README.md

File metadata and controls

46 lines (32 loc) · 1.44 KB

Starting server:

int port = 8005;
string host = Dns.GetHostName();
IPAddress IP = Dns.GetHostAddresses(host)[1];
IPEndPoint ipPoint = new IPEndPoint(IPAddress.Parse(IP.ToString()), port);
var listenSocket = new CListeningSocket();
CPool cPool = new CPool(listenSocket);
listenSocket.Bind(ipPoint);
listenSocket.Listen(10);

image

Connecting to the server from the client:

var ipPoint = new IPEndPoint(IPAddress.Parse("YOUR IP ADDRESS"), port);
CClientSocket socket = new CClientSocket();
CPool cPool = new CPool(socket);
cPool.Init(ipPoint);

image

Receiving message in server:

var res = cPool.ProcessAccept();
Log($"Received message: {res.StringResult}");

image

Sending a message from the server to the client:

cPool.Send($"We received message {res.StringResult} from you. You are very COOOOl", res.handler);

image

Receiving message of server in the client:

cPool.ProcessRead()

image