Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

I have a server listening on a socket file /tmp/any.sock and I want to write something to that socket. If it would be listening on a port, I would use echo mymessage | nc localhost 1234, but nc /tmp/any.sock or echo mymessage > /tmp/any.sockdoes not work.

share|improve this question
up vote 4 down vote accepted

You can use nc for it as well with the -U option.


  1. Open listening socket in one terminal

    nc -lU socket.sock
  2. Input of data on the other terminal:

    echo mytext | nc -U socket.sock
  3. Watch the mytext being printed on the first terminal. By default nc stops listening after an End-of-File character, but I assume your server can decide on its own.

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.