I'd like to redirect an applications input and output to a unix socket and connect to that socket from another session. What I'm doing so far is the following:

On the "server" side:

socat EXEC:"command" UNIX-LISTEN:/tmp/comm

And on the "client" side:

socat UNIX-CONNECT:/tmp/comm -

It works pretty good, but as soon as the client-side socat terminates, the server terminates, too. But I'd like it to keep running and reconnect later... How do I accomplish that?


You must use fork option, which handle a connection in a child process, make the parent process attempt to handle more connections.

In first terminal:

$ socat - UNIX-LISTEN:/tmp/comm,fork

In second terminal:

$ socat UNIX-CONNECT:/tmp/comm -

Press Ctrl+C in second terminal, switch to the first terminal and see your server is still running.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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