in reply to Re: Win32 fork and IO::Socket::INET->accept calls
in thread Win32 fork and IO::Socket::INET->accept calls
I can easily make your code work, just by adding a Timeout to your socket, which you should have any way. A server socket without timeout can run into many problems. Other than the problem you demo'd here, it could also become a dead socket (a socket that cannot be awakened by accept()), if you leave it idle for long enough.
use strict; use warnings; use IO::Socket::INET; $|=1; my $server = IO::Socket::INET->new( Proto => 'TCP', LocalPort => 2500, Reuse => 1, Listen => 10, Timeout=>1 ); 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.$/");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Win32 fork and IO::Socket::INET->accept calls
by ikegami (Patriarch) on Nov 04, 2004 at 04:27 UTC | |
by pg (Canon) on Nov 04, 2004 at 04:38 UTC | |
by ikegami (Patriarch) on Nov 04, 2004 at 04:49 UTC | |
by pg (Canon) on Nov 04, 2004 at 04:56 UTC | |
by ikegami (Patriarch) on Nov 04, 2004 at 05:05 UTC |