Script to bind to socket

i need to come up with a script that when run from the command line, it will bind to a socket, and listen for tcp connections on a certain port.

something like:

### ./connection_listener 5666

i found the following script on the web but when i run it, it complains about "accept" not being available.

perl -MIO::Socket::INET -ne 'BEGIN{$l=IO::Socket::INET->new(
  LocalPort=>5666,Proto=>"tcp",Listen=>5,ReuseAddr=>1);
  $l=$l->accept}print $l $_' 

OS: Linux/SunOS/HPUX/AIX

I endorse using netcat for this.
"nc -l 3343 " begins listening on port 3343. I've used this to tie serial to TCP/IP, strait TCP/IP, etc. See

:slight_smile:

1 Like