#!/usr/bin/perl -w use strict; use warnings; use IO::Socket::INET; my $sock = ''; startListening(); sub startListening(){ $sock = new IO::Socket::INET( LocalPort => '8080',Porto => 'tcp',Listen => '1', Reuse => '1') or die "Could not create socket \n" unless $sock; my $new_sock = $sock->accept() or die "Lost connection\n"; if ($new_sock){ print "Received incoming connection on port \n"; #close ($new_sock); close($sock); exit; } }