How to create a TCP listener?

You could use nc -l as a method to do what you are looking for. Some implementations of nc have a -L option which allows the connections to persist.

If you only need them for a little while you could open this command in a for loop and have a bunch of ports opened that way.

If you need these opened longer you can use one of the super servers to create a daemon.


you can create a port listener using Netcat .

root@ubuntu:~# nc -l 5000

you can also check if port is open or not using netstat command .

root@vm-ubuntu:~# netstat -tulpen | grep nc
tcp        0      0 0.0.0.0:5000             0.0.0.0:*               LISTEN      0          710327      17533/nc

you can also check with nc :

Netcat Server listener :

nc -l localhost 5000

Netcat Client :

root@vm-ubuntu:~# nc -v localhost 5000
Connection to localhost 5000 port [tcp/*] succeeded!

if port is not open

root@vm-ubuntu:~# nc -v localhost 5000
nc: connect to localhost port 5000 (tcp) failed: Connection refused

Listen using netcat.

# nc -l 5555

Check using ss

# ss -nat|grep 5555
LISTEN     0      1                         *:5555                     *:*
#