Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the simplest way to do the following thing?

Run a program which will open specified port, listen for it, and display whatever it receives. Also if type something -- then send back to connected peer.

This is for debug purposes.

share|improve this question
You can use thegeekstuff.com/2012/04/nc-command-examples for the same – Rahul Patil Jan 2 '13 at 10:08
up vote 3 down vote accepted

Server listens on port 8000:

$ nc -l 8000

Client connects to port 8000:

$ nc localhost 8000 
share|improve this answer
This doesn't answer the question. The poster wanted to display what the client sends. The only way I see is to use the "-c" or "-e" option but I'm hoping there's a solution using only pipes. – user7000 Aug 2 '14 at 3:23

This sounds like a job for Gnu Netcat (nc)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.