B
Bruce Vander Werf
I am developing a network client application (using the Socket class)
that will need to make simultaneous TCP connections to many (100 or
more) servers. In this case, which would be a better strategy:
1) Create a thread for each connection and use blocking receives,
2) Use asynchronous receives (BeginReceive/EndReceive)
In both cases, I will also be sending data on the socket from the main
thread.
Followup questions -
If using blocking sockets, can I safely call Socket.Send from the main
thread while blocking on Socket.Receive from a secondary thread?
If using asynchronous sockets, can I call BeginReceive for each Socket
as it is connected, using a common EndReceive method? Any problem
making arbitrary Send or BeginSend calls on these sockets from the
main thread while processing receives asynchronously?
Thanks...
--Bruce
that will need to make simultaneous TCP connections to many (100 or
more) servers. In this case, which would be a better strategy:
1) Create a thread for each connection and use blocking receives,
2) Use asynchronous receives (BeginReceive/EndReceive)
In both cases, I will also be sending data on the socket from the main
thread.
Followup questions -
If using blocking sockets, can I safely call Socket.Send from the main
thread while blocking on Socket.Receive from a secondary thread?
If using asynchronous sockets, can I call BeginReceive for each Socket
as it is connected, using a common EndReceive method? Any problem
making arbitrary Send or BeginSend calls on these sockets from the
main thread while processing receives asynchronously?
Thanks...
--Bruce