Using socat to exec php cli

Posted by RoyHB on Server Fault See other posts from Server Fault or by RoyHB
Published on 2012-12-03T10:41:25Z Indexed on 2012/12/03 11:18 UTC
Read the original article Hit count: 207

Filed under:

There are multiple client programs that periodically connect to a port on my server and send a single line of text.

When a connection to the port is made I need to start a PHP CLI script that processes the data. There may be many of the remote scripts running/connecting at more or less the same time so I think it would be best if socat forked a process for each connection to run the script.

I've gotten socat to do most of what I need, using the command

socat tcp-l:myport,fork exec:mypath/socatTest.php

I can read the input on php://stdIn. All is good.

The problem is that the process doesn't seem to fork, so if a second external program sends data while another is doing the same it gets a connection refused error.

Where have I gone wrong?

© Server Fault or respective owner