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. (socat
lacks 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
-s
to run command only a single time if-n0
(default) is used. -
Option
-n-X
to increase the number of parallel runningcommand
s toX
-
Option
-nX
to prefork, that issocklinger
forks before theaccept()
. -
killall -1 socklinger
gracefully shuts down socklinger -
Environment in the forked program:
SOCKLINGER_NR
internal number of the connectionSOCKLINGER_PEER
peer name (IP:port)SOCKLINGER_SOCK
socket name from commandlineSOCKLINGER_MAX
maximum parallel processesSOCKLINGER_COUNT
count of processes forked at time when this spawnedSOCKLINGER_PID
PID of socklinger parentSOCKLINGER_NOW
timestamp as reference
(This README currently is terribly incomplete.)