tos@homer ~/tos/tmp
# cat recip
#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket;
my $socket=new IO::Socket::INET (LocalPort => 1960,
Proto => 'tcp',
Listen => 5,
Reuse => 1,
);
die "could'nt create socket: $!" unless $socket;
while (my $new_socket = $socket->accept()) {
while (defined (my $buf = <$new_socket>)) {
print $buf;
$buf =~ /^ls/ && do { system ("ls") };
}
}
close ($socket);
####
tos@VRANZ /cygdrive/t/tos/tmp
# cat sndr
#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket;
my $socket=new IO::Socket::INET (PeerAddr => 'homer',
PeerPort => 1960,
Proto => 'tcp'
);
die "couldn't create socket: $!" unless $socket;
foreach (1..3) {
print $socket "message $_\n";
$socket->flush();
}
print $socket "ls\n";
$socket->flush();
close ($socket);
####
tos@VRANZ /cygdrive/t/tos/tmp
# perl sndr
tos@VRANZ /cygdrive/t/tos/tmp
#
####
tos@homer ~/tos/tmp
# perl recip
message 1
message 2
message 3
ls
recip sndr sndr~ x