open ($fd, ">&$fnum") or die;
$fd is now a descriptor that I can write to and it works like a champ. Sort of, and hence my question. I'm hoping I just have the open syntax wrong in which case the fix might be a simple one.
First I run the script and monitor the open sockets with netstat. Then I run a test script that simply connects to that socket and does a sysread, prints the results, closes the connection and exits.
Netstat shows the initial connection and then the socket goes into FIN_WAIT2 and hangs around for quite awhile or until I close my main script. On the other hand if I run the code non-threaded and do all the communications inline, I see the socket go to FIN_WAIT2 and then fairly quickly goes away.
My guess is that this is when the socket is closed by the test script, that close is detected and acknowledged by the thread where it was created, but copy of the socket that was created with the open() is not completing the communications handshake and I don't know enough about these mechanisms to know what to do.
Any help will be greatly appreciated.
btw - I also tried using the open technique in some non-threaded code and it too works correctly but leaves a connection in FIN_WAIT2 as well, so I'm guessing this has nothing to do with threads and more to do with having to close that second handle.
-mark
In reply to Sharing sockets between the main script and thread by markseger
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |