in reply to Re: Sharing sockets between the main script and thread
in thread Sharing sockets between the main script and thread

Excellent! I couldn't quite do it the way you suggested for a couple of reasons, one being that I'm doing my accepts in the thread vs the main stream code so the logic would need to be reversed but more significant is the fact that the thread is stuck in a select->can_read(), waiting for connection requests and can't do that and watch a queue at the same time unless I wrap all that in an outer loop with a timeout and didn't want to do that.

Nevertheless, since I am passing around the file numbers in a shared hash from the thread to the main code, I'm able to set it to a 'special' value when the socket is closed in the thread to tell the main line to close his end as well.

In any event, the key to all this is it need to close the second descriptor and that did the trick. Seems to work like a champ, at least so far...

-mark

  • Comment on Re^2: Sharing sockets between the main script and thread

Replies are listed 'Best First'.
Re^3: Sharing sockets between the main script and thread
by BrowserUk (Patriarch) on Nov 25, 2008 at 13:11 UTC