See also archive.org version of Apache on lingering
This is a tool to, basically, listen on a socket and call a script to serve the request.
It can do connects, too, or connect two programs with a socketpair to communicate with each other.
The interesting part here is, that it lingers on the socket before the connection is closed, such that the other (receiving) side has enough time to read all data from the socket. Without this, some last data might get lost.
For a more versatile program see
socat. However it is not easy to use. (socatlacks transparent proxy support).
git clone https://github.com/hilbix/socklinger.git
cd socklinger
git submodule update --init
make
sudo make install
socklinger -h
socklinger socket command
socklinger [options] socket command args..
-
Option
-sto run command only a single time if-n0(default) is used. -
Option
-n-Xto increase the number of parallel runningcommands toX -
Option
-nXto prefork, that issocklingerforks before theaccept(). -
killall -1 socklingergracefully shuts down socklinger -
Environment in the forked program:
SOCKLINGER_NRinternal number of the connectionSOCKLINGER_PEERpeer name (IP:port)SOCKLINGER_SOCKsocket name from commandlineSOCKLINGER_MAXmaximum parallel processesSOCKLINGER_COUNTcount of processes forked at time when this spawnedSOCKLINGER_PIDPID of socklinger parentSOCKLINGER_NOWtimestamp as reference
(This README currently is terribly incomplete.)