开发者

Using one socket object to send and receive multiple sockets in C#

开发者 https://www.devze.com 2023-02-10 18:41 出处:网络
In C#, I have a server application with multiple clients connecting.I will only keep track of the IP address and port when a new socket is instantiated upon开发者_如何学Go accept.My question is that u

In C#, I have a server application with multiple clients connecting. I will only keep track of the IP address and port when a new socket is instantiated upon开发者_如何学Go accept. My question is that using only one socket object can I accommodate sending and receiving? Is it possible for synchronous and asynchronous sockets? Examples will be helpful. Thanks in advance.


It's possible with UDP, it's not possible with TCP and since you mention Accept() I assume you're using TCP and therefore it's not possible...


You have to use the socket object that is returned by accept method to send and receive to particular client. you can not use a single socket for all clients. socket is the end point through which communication is done

0

精彩评论

暂无评论...
验证码 换一张
取 消