#!/usr/bin/perl use strict; use warnings; use IO::Socket; my $server=IO::Socket->new( Domain=>AF_INET, Proto=>'tcp', LocalPort=>'1234', Listen=>SOMAXCONN, ); $server->timeout(10); my $connection=$server->accept; if ($connection) { print "Got a message.\n"; close $connection; } else { print "Timed out.\n"; }