#!/usr/bin/perl -w
use strict;
use IO::Socket;
my $new_sock;
my $buf;
my $sock = new IO::Socket::INET (LocalHost => 'foo',
localPort => 1880,
Proto => 'tcp',
Listen => 5,
Reuse => 1
);
die "Unable to create socket: $!" unless $sock;
print "Waiting for message...\n";
while ($new_sock = $sock->accept()) {
print $buf while (defined ($buf = <$new_sock>))
}
close ($sock);
####
#!/usr/bin/perl -w
use strict;
use IO::Socket;
my $sock = new IO::Socket::INET (PeerAddr => 'foo',
PeerPort => 1880,
Proto => 'tcp'
);
die "Could not create socket: $!\n" unless $sock;
while (1) {
print "Enter message: ";
chomp (my $msg = );
print "Sending $msg\n";
print $sock "$msg\n";
$sock->flush;
}
close ($sock)
####
my $sock = new IO::Socket::INET (LocalHost => 'sgilbertdt',
localPort => 1200,
Proto => 'tcp',
Listen => 5,
Reuse => 1
);