Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 1 down vote accepted

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

Example

  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
add comment

Your Answer

 
discard

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.