View Single Post

  #1 (permalink)  
Old 02-01-2004
Boris Bak
 
Posts: n/a
Default Calling close(sock) in one thread doesn't make recv(sock,...) return

Hi,

I am running a library on Red Hat 8.0.

It has 2 threads. In one thread I do recv(sock,...), which blocks until
data is received. When application that called the library exits, the
library executes clean-up code as part of which it calls close(sock) on
the same socket that recv(sock,...) was issued before. And then does
pthread_join() to wait for the reading thread to finish

What I notice is recv(sock,...) never returns, which makes my join()
hang. If I press Ctrl-C, it seems to terminate the recv and allows the
clean-up code to finish normally.

Does anybody know a way to terminate a recv(sock,...), besides close()?
And why does the close() don't do the job in the first place?

Thanks for you help!

boris

Reply With Quote