Create a TCP Client and Server and Send Messages with Netcat

This post shows how to create a TCP client and server and send messages between them using netcat v1.12 on Windows
Steps
1. Download netcat v1.12 for windows from http://eternallybored.org/misc/netcat/ (or click here to get it)
2. Open a CMD window
3. Create the server by typing this into the CMD window
nc -l -p 12345
4. Open another CMD window
5. Create the client by typing this into the CMD window you just opened:
nc localhost 12345
6. Type Hello, World in the client. You should see it in the server.
Good links
-
Netcat cheatsheet here
-
Establishing a connection and getting some data over HTTP from Jon Craton
-
Download netcat v1.12 here
-
A Gentle Introduction to netcat by Zheng Hao Tan
-
netcat commands by Jon LaBelle
-
A cool webserver in one line from Christoph Champ’s Personal Wiki
-
{ echo -ne “HTTP/1.0 200 OK\r\nContent-Length: $(wc -c <some.file)\r\n\r\n”; cat some.file; } nc -l 8080
Reference
- Cat pic from link