Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
And the server:#!/usr/bin/perl -w use IO::Socket; my $sock = new IO::Socket::INET ( PeerHost => shift || 'localhost', PeerPort => 7070, Proto => 'tcp', ); die "Could not create socket: $!\n" unless $sock; print $sock "Hello there!\n"; close($sock);
#!/usr/bin/perl -Tw use IO::Socket; my $sock = new IO::Socket::INET ( LocalHost => 'localhost', LocalPort => shift || 7070, Proto => 'tcp', Listen => 1, Reuse => 1, ); die "Could not create socket: $!\n" unless $sock; my $socket; my $data; for ( ; $socket = $sock->accept(); close $socket) { while ($data = <$socket>){ print $data; } } close($sock);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Socket problem
by gbarr (Monk) on Oct 03, 2001 at 18:33 UTC | |
by Anonymous Monk on Oct 03, 2001 at 18:49 UTC |