LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   recv() is not coming out of blocking after closing the socket. (https://www.linuxquestions.org/questions/linux-networking-3/recv-is-not-coming-out-of-blocking-after-closing-the-socket-459461/)

arunka 06-29-2006 10:01 AM

recv() is not coming out of blocking after closing the socket.
 
Hi All
I have a server which is mutithreaded.
One of the thread is blocking on recv(),
If from another thread i close the socket, the recv() is not coming out of blocking.
If i do the same in windows it is working correctly.
Can anyone help??

Thanks in advance
Arun KA

Peterius 06-30-2006 09:07 PM

Is the close successful? There might be something like a usage count on the file handle for the socket and until its 0 the socket remains open. Each thread might add to that usage count. I haven't done this stuff in a while but chances are your code needs to be rewritten to get the desired effect. Post a little more information about what you're trying to do and the situation perhaps?

btmiller 06-30-2006 09:52 PM

I'm not sure offhand, but the behavior could be due to the differences in thread semantics between Windows and Linux. You could set the file descriptor nonblocking and periodically check and make sure that the file descriptor hasn't been closed.


All times are GMT -5. The time now is 02:51 AM.