Attach process with port 2222

Hi Team,

is there any way, I can start any process for e.g. run a shell script (infinite loop) and attach it to port 2222?

I am trying to create a scenario where an application will start running at port 2222 and I will telnet the same to confirm, application port is listening.
So, requirement is, running a demo process at port 2222 and doing further checks.

Thanks
Vivek

You can use nc (or netcat) to listen to a particular port:-

 
 nc -l 2222
 

From nc manual page:-

     -l      Used to specify that nc should listen for an incoming connection rather than initiate a connection to a remote host.