jptxs has asked for the wisdom of the Perl Monks concerning the following question:
the server:
use strict; use warnings; use IO::Socket::INET; my $socket = IO::Socket::INET->new( LoclaPort => 1776, Type => SOCK_STREAM, Reuse => 1, Listen => 10 ) or die "Big Problem with the Server, Man : $!\n\n"; while ( my $client = $socket->accept() ) { { my $child; # perform the fork or exit die "Can't fork: $!" unless defined ($child = fork()); if ($child == 0) { #i'm the child! #close the child's listen socket, we dont need it. $socket->close; #call the main child rountine print $client 'Hello, down there!!', "\n\n"; #if the child returns, then just exit; exit 0; } else { #i'm the parent! #who connected? warn "Connecton recieved ... ",$client->peerhost,"\n"; #close the connection, the parent has already passed # it off to a child. $client->close(); } #go back and listen for the next connection! } } close($socket);
the client:"A man's maturity -- consists in having found again the seriousness one had as a child, at play." --Nietzsche
I've looked in the Camel; I've seen MP3 server with IO::Socket (stealum much code there), Where can I find resources about Socket, IO::Socket, IO::Socket::INET, and forking server but nothing going from any of them...use strict; use warnings; use IO::Socket::INET; my $socket = IO::Socket::INET->new( PeerAddr => 'localhost', PeerPort => '1776', Proto => "tcp", Type => SOCK_STREAM) or die "Big Problem, Man : $!\n\n"; my $response = <$socket>; print $response, "\n\n" if $response; close($socket);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: IO::Socket::INET server(?)
by wardk (Deacon) on Feb 13, 2001 at 01:36 UTC | |
by jptxs (Curate) on Feb 13, 2001 at 01:42 UTC | |
|
Re: IO::Socket::INET server(?)
by chipmunk (Parson) on Feb 13, 2001 at 01:37 UTC |