It seems that accept on a inherited handle is no good.
Works:
use strict; use warnings; $|=1; if (fork() == 0) { print("$$: Child 1.$/"); sleep(3); } elsif (fork() == 0) { print("$$: Child 2.$/"); sleep(3); } else { print("$$: Parent.$/"); sleep(3); } print("$$: oye.$/");
Works:
use strict; use warnings; use IO::Socket::INET; $|=1; if (fork() == 0) { print("$$: Child 1.$/"); my $server = IO::Socket::INET->new( Type => SOCK_STREAM, Proto => 'TCP', LocalPort => 2500, Reuse => 1, Listen => 10 ); $server->accept(); } else { sleep(1); # Make sure accept is reached. if (fork() == 0) { print("$$: Child 2.$/"); sleep(3); } else { print("$$: Parent.$/"); sleep(3); } } print("$$: oye.$/");
Doesn't Work:
use strict; use warnings; use IO::Socket::INET; $|=1; my $server = IO::Socket::INET->new( Type => SOCK_STREAM, Proto => 'TCP', LocalPort => 2500, Reuse => 1, Listen => 10 ); if (fork() == 0) { print("$$: Child 1.$/"); $server->accept(); } else { sleep(1); # Make sure accept is reached. if (fork() == 0) { # <------ Doesn't returns until accept returns. print("$$: Child 2.$/"); sleep(3); } else { print("$$: Parent.$/"); sleep(3); } } print("$$: oye.$/");
Could this be related to the fact that fork doesn't actually fork in Win32? (It just starts a new thread.)
In reply to Re: Win32 fork and IO::Socket::INET->accept calls
by ikegami
in thread Win32 fork and IO::Socket::INET->accept calls
by BUU
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |