LJ Archive

Listing 4: Perl for Router Client

#!/usr/bin/perl
[...]
sub contactRouters {
  [...]
  socket(SOCK, PF_INET, SOCK_STREAM, $proto) ||
     die "socket: $!";
  connect(SOCK, $paddr) || die "connect: $!";
  SOCK->autoflush(1);
  print SOCK $line;
  recv(SOCK, $buffer, 80, 0);
  close (SOCK)  || die "close: $!";
  [...]
}
LJ Archive