Lucas Rey has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use IO::Socket::INET; $SIG{CHLD} = sub {wait ()}; my $socket = new IO::Socket::INET ( LocalHost => '0.0.0.0', LocalPort => '5000', Proto => 'tcp', Listen => 5, Reuse => 1); die "cannot create socket $!n" unless $socket; while ($new_sock = $socket->accept()) { $pid = fork(); die "Cannot fork: $!" unless defined($pid); if ($pid == 0) { # This is the fork child $new_sock->recv(my $data, 500); print "$data\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: TCP Server using fork to accept multiple requests
by Corion (Patriarch) on Aug 17, 2022 at 07:59 UTC | |
by Lucas Rey (Sexton) on Aug 17, 2022 at 09:41 UTC | |
|
Re: TCP Server using fork to accept multiple requests
by tybalt89 (Monsignor) on Aug 17, 2022 at 09:22 UTC | |
by NERDVANA (Priest) on Aug 20, 2022 at 14:40 UTC | |
by tybalt89 (Monsignor) on Aug 20, 2022 at 16:29 UTC | |
by NERDVANA (Priest) on Aug 20, 2022 at 23:26 UTC | |
|
Re: TCP Server using fork to accept multiple requests
by Anonymous Monk on Aug 17, 2022 at 09:14 UTC |