#!/usr/bin/perl -w $PF_INET = 2; $SOCK_STREAM = 1; $port = 9999; $pattern = 'S n C4 x8'; # Create an address using 0.0.0.0. $this_addr = pack($pattern,$PF_INET, $port, 0,0,0,0); $proto = getprotobyname("tcp"); socket(SERVER, $PF_INET, $SOCK_STREAM, $proto) or die "Can't create socket: $!"; bind(SERVER, $this_addr) or die "Can't bind: $!"; listen(SERVER,1) or die "Can't listen: $!"; print "Server listening on port $port\n"; for ( ; $paddr = accept(CLIENT,SERVER); close(CLIENT) ) { print CLIENT "Hello from server.\n"; }