#!/usr/bin/perl -w use IO::Socket; $port = 9999; $server_socket = IO::Socket::INET->new( LocalPort => $port, Listen => SOMAXCONN, Proto => 'tcp', Reuse => 1) or die "Cannot open socket: $!"; print "Server listening on port $port\n"; while ( $client_socket = $server_socket->accept() ) { $client_host = $client_socket->sockhost(); print $client_socket "Hello from server.\n"; print "Sent message to client on $client_host.\n"; $client_socket->close(); }