use IO::Socket; $sock = new IO::Socket::INET( LocalAddr => 'localhost', #if i was to plug an IP in as the value for LocalAddr, wouldn't work LocalPort => 1200, Proto => 'tcp', Listen => 10, Reuse => 1 ); die $! unless $sock; while ( $new_sock = $sock->accept() ) { $clnt = $sock->sockhost(); print "New connection from $clnt...\n"; while ( $buf = <$new_sock> ) { print $buf; } print "Client disconnected...\n"; } close( $sock ); #### use IO::Socket; $sock = new IO::Socket::INET( PeerAddr => 'localhost', # an IP here and the script fails to connect PeerPort => 1200, Proto => 'tcp' ); die "Socket could not be created: $!\n" unless $sock; $msg = ; while ( $msg !~ m/^\n$/ ) { $inp = $msg; undef( $msg ); print $sock "MSG: $inp"; $sock->flush(); $msg = ; } close( $sock );