Sending a simple TCP message using Netcat
By John Parsons •
I am trying to use netcat to send a simple message over TCP, e.g. I want to send the digit 1.
So I understood that I write the following in the terminal, after installing netcat
netcat [ip-address] [port]
But how do I specify the message to be sent? i.e. where to I write "1" ?
2 Answers
Create file something.txt, content of file is 1
netcat [ip-address] [port] <something.txtAt destination you must have something to listen to this.
or
Server:
netcat -l -p [port]to listen to the connection
Client:
netcat [server-ip-address] [port]After connection is establish on cilent simple type1 and hit enter
I use:
echo text | netcat host portSo you would just need to run this:
echo 1 | netcat localhost 12345 1