Paul - The Programmer

simple & stupid
Good Linux tool, Module Assistant
Change the Gnome Commander default editor

Good Linux tool, netcat

paul posted @ Tue, 15 Mar 2011 23:02:35 +0800 in about debian with tags Linux Debian netcat nc , 3436 readers

Netcat, as know as nc, is a simple command line tool to send and receive data with TCP or UDP protocal.

There are many tutorials for the netact on the internet, since it has been wildly used as a back-end tool to :

  • Simulate server
  • Scanning ports
  • File transfers
  • Proxy gateway
  • Many other things to transfer data with TCP/UDP from one place to another.

Hence here I'd like to show you something different, an example of how to create a echo server with netcat.

The server side just as simple as one line command:

$ nc -l -p 12345 -c 'while true; do read i && echo [echo] $i; done'

Then the telnet can be used as a client to connect to the nc server

$ telnet localhost 12345
hello
[echo] hello

Once you input any string, the server returns your input with [echo] prefix.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.

Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter