PDA

View Full Version : [SOLVED] recv() and send() in two different threads



dawwin
June 26th, 2010, 06:53 PM
Hello everyone, it's my first post here

I've got following situation:
I want to create two threads - first to read data from socket (using blocking function recv()) and second to send data to the same socket using send() function.

Is it okay to use send() when recv() is locked on the same socket?

dwhitney67
June 26th, 2010, 10:40 PM
Yes.


P.S. IMHO, you should avoid calling recv() unless you have been notified that there is data to be read on the socket. Look at the man-page for select(), for this will assist you in determining when there is data to be read.

dawwin
June 26th, 2010, 10:51 PM
Thanks