#!/usr/bin/perl -w use strict; use warnings; use IO::Socket; my $port = shift or die "usage: $0 port"; my $sock = IO::Socket::INET->new( LocalPort => $port, Listen => 1, Reuse => 1 ); while (my $c = $sock->accept() ) { my $remotename = $c->peerhost(); my $remoteport = $c->peerport(); print "Got a connection on port $port from $remotename:$remoteport\n"; }