use strict; use Socket; my $socket; my $port = 4000; my $ipaddr = "localhost"; socket($socket, PF_INET, SOCK_STREAM, getprotobyname('tcp')) || die "Could not create socket: $!\n"; connect($socket, sockaddr_in($port, inet_aton($ipaddr))) || die "Could not connect: $!\n"; my $message; my $messageLen = 999999; # the maximum number of bytes to read off the socket defined(send($socket, "1", 0)) || die "Send error: $!"; defined(recv($socket, $message, $messageLen, 0)) or die "Receive error: $!"; print "I got the following message: $message.\n"; shutdown($socket, 2);