1

I found this answer by @jeremytrimble on Stack Overflow which explains how you can read a FIFO file over network.

I wonder if it’s possible to start these netcat commands automatically, e.g. in a crontab file (@reboot nc …). How would I keep them alive or have them restarted after they are killed?

Host1$ mkfifo Host1_named_pipe
Host1$ nc -l 1234 > Host1_named_pipe

Host2$ mkfifo Host2_named_pipe
Host2$ nc Host1 1234 < Host2_named_pipe

Now, when you run a program on Host2 and send its output to Host2_named_pipe, that output will come out of Host1_named_pipe on Host1.

1 Answer 1

0

On the server which is always connected use this in a crontab:

@reboot nc -k -l 1234 < /tmp/fifo.fifo

On the client which is not always on the network or switched on use this command:

nc -d $IP_OF_SERVER 1234 > /tmp/fifo.fifo & $SOME_COMMAND

The server listens always for a connection on the specified port (thanks to the -k parameter), the client just connects to the server when it needs to.

I’m using this for MPD and its FIFO visualizer. MPD runs on a remote host, but my MPD client runs locally (I’m using ncmpcpp).

This is the important part of the ncmpcpp config on the local host:

mpd_host = "$IP_OF_SERVER"
visualizer_fifo_path = "/tmp/fifo.fifo"

This is the important part of the mpd config on the remote server:

audio_output {
        […]
        path    "/tmp/fifo.fifo"
        […]
}

Running the 'nc' command on my local machine seems to use a very high amount of resources … ~100% of my CPU performance.

You must log in to answer this question.

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