Super User is a question and answer site for computer enthusiasts and power users. 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

This is question is somehow related to How is it called when listening(connecting) two sockets and exchanging data between them?

In the test setup I have three terminal windows open I run in

Term1: "nc -l 55545"
Term2: "nc -l 55546"
Term3: "socat tcp:localhost:55545 tcp:localhost:55546"

Input to Term1 now appears in Term2 and input to Term2 appears in Term1.

This is the desired behavior. How can I achieve this behavior by only using nc?

When I run in

Term3: "nc localhost 55545 | nc localhost 55546"

then Input to Term1 appears in Term2 but input to Term2 appears in Term3. How can I make the pipe bidirectional? If possible without temporary files.

share|improve this question

This comes straight from the Wikipedia page on netcat. In Term3, you would run:

mkfifo backpipe
nc localhost 55545 0<backpipe | nc localhost 55546 1>backpipe

This does pretty much exactly what you want. It uses a FIFO to get output from the left-hand side back into the right-hand side. It's not, strictly speaking, a temporary file -- a FIFO is a named pipe between two processes.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .