Skip to content

komdil/SocketChat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published

Languages