Async TCP server with many connections
How to create an async TCP server which can handle many connections without creating a dedicated thread for each one?
-
ReceiveAsync(...)
without SocketAsyncEventArgs
is blocking (when being awaited) -> ❌ I guess?
- ReceiveAsync(...)
with SocketAsyncEventArgs
is not blocking -> ✅ I guess?
- BeginReceive(...)
does not block and uses the (async) callback mechanism -> ✅ I guess?
Which one to use?4 Replies
People recommend to use AcceptAsync and ReceiveAsync
Thanks a lot! I just saw that the code in question is using
TcpClient
Would you still use ReceiveAsync(...)
via tcpClient.Client.ReceiveAsync(...)
or tcpClient.BeginRead(...)
?Based on previous conversations, Begin methods are methods you should not use anymore. Though they are easier.
Aight, thanks a lot!