开发者

.net tcp client async model

开发者 https://www.devze.com 2023-02-06 15:22 出处:网络
I need to implement a TCP client that will send data to the server and also receive messages. The com开发者_运维知识库munication model should be asynchronously. Do you have a good example of doing th

I need to implement a TCP client that will send data to the server and also receive messages. The com开发者_运维知识库munication model should be asynchronously. Do you have a good example of doing this? Do i need to implement that on another thread ... that keeps constantly reading from the socket? ... or I can use the BeginReceive pattern of the socket?

Thanks, Radu


When you connect over TCP to the server you get a duplex channel so the server can talk back to the client in the same socket.

About using the begin receive you can use it to avoid creating worker threads and constantly reading the socket (the same way you can use BeginSend). Without anymore information about what you're trying to do, that's the best I can give you... yes you can. :)

0

精彩评论

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