Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by markseger (Beadle)
on Nov 25, 2008 at 13:01 UTC ( #725833=note: print w/ replies, xml ) Need Help??


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
Re^3: Sharing sockets between the main script and thread
by BrowserUk (Pope) on Nov 25, 2008 at 13:11 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://725833]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2014-11-28 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (194 votes), past polls