Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting a TCP server from terminal

How do I start a TCP server from the terminal on port 13370 using nc? I was following a tutorial that required starting up a TCP server on 13370 and send requests through it. The tut advised me to open the TCP server using "nc" How do I go on achieving this?

like image 758
ritvik1512 Avatar asked Jul 16 '15 06:07

ritvik1512


1 Answers

From nc documentation:

It is quite simple to build a very basic client/server model using nc. On one console, start nc lis-tening listening on a specific port for a connection

You should use -l parameter, for listening on port 13370:

$ nc -l 13370

Now you have a tcp server on 127.0.0.1:13370

On a second console you could connect to your server by using:

$ nc 127.0.0.1 13370

Please refer also to the official documentation link.

like image 162
teoreda Avatar answered Sep 30 '22 19:09

teoreda