kim24dc
January 26th, 2005, 03:56 PM
I was wondering how blocking sockets (TCP) work when you do a send and receive at the same time. Specifically I was wondering about the 2 cases below:
1) There are two threads. The first thread is pending on a recv() call on the socket and no messages are coming in. The second thread needs to send a message on the same socket. Can the second thread send a message while the first thread is pending on the receive? Is this all transparent to the application layer?
2) If 1) is true, is it possible for a send to get pre-empted in the middle if a message is received, while the send is taking place? If so, does this cause any errors in send or recv?
In general, is there any possiblities of socket or data collisions when trying access the same socket in multiple threads?
Thanks
1) There are two threads. The first thread is pending on a recv() call on the socket and no messages are coming in. The second thread needs to send a message on the same socket. Can the second thread send a message while the first thread is pending on the receive? Is this all transparent to the application layer?
2) If 1) is true, is it possible for a send to get pre-empted in the middle if a message is received, while the send is taking place? If so, does this cause any errors in send or recv?
In general, is there any possiblities of socket or data collisions when trying access the same socket in multiple threads?
Thanks