[jump to content][No Software Patents]Tools (new) : socklinger [ Home | Scylla+Charybdis old home | Tools (old) | Tools (new) | FAQ | Downloads ]

Moving to GitHub, slowly

The software on this pages will slowly be moved to GitHub https://github.com/hilbix/. The CVS repository will be migrated to GIT as well, so the history will be preserved, a bit. See FAQ.

Scylla and Charybdis, socklinger - Tools

The tools are developed under Linux with ESR's paradigm release early, release often in mind.
So you can consider this beta software, or alpha, or pre-alpha, or even worse ;)

Have a look in the download directory for all downloads.
As always here, all you get is the source. No binaries here.

socklinger 2.4.0-20100126-154808

Execute quick hack shell scripts connected to a socket.


⇒ ⇒ ⇒ The development shifted to another location. All future versions will be published at https://github.com/hilbix/socklinger   ⇐ ⇐ ⇐


If you look for something of more wide use perhaps have a look at socat (this is from somebody else, don't ask me about socat, however I highly recommend socat if you are not satisfied with socklinger!).

Socklinger is thought for admins in a networked environment, who want to write some quick hack bash scripts to rapidly implement a socket based thingie just to get something done and reuse this solution for themself later on, too. Socklinger definitively is not designed to offer a production service to customers. But it's just what *you* need to get *your* weird network script running for *your* needs, saving *your* time.

When you want to write a quick hack, shell is convenient. However when you want to do this with networking scripts you often will observe stange effects if you call scripts from inetd. This is, because the "lingering" on sockets is extremely short (or missing) nowadays to protect against DoS-attacks. The effect is, that you will observe that the end of the output of the script just is not transmitted to the other side. Socklinger fixes this and restores, what you know from your good old and reliable SunOS from 1988.

Note that you might be tempted to use the exec-option of netcat, too. However netcat cannot reuse sockets on stdin like in inetd usage or when something is running under tcpd-control. And you don't have control over the number of scripts running in parallel.

Note that you can run scripts under tcpserver, too. However you will observe the linger-problem there. Often you can fix the problem by adding a "sleep 10" at the end of the script. However the hope that 10 seconds are long enough is no solution in my eyes. And often the sleep period slows down the other side, because the othere side waits until the socket is closed. (Any software which relies on the kernel linger implementation may fall into the same trap as tcpserver.)

Socklinger is designed as a solution for quick hacks, so it's enough to only run one script in parallel. This way you don't have to bother about race conditions in the script. Socklinger also allows you to reuse the socket which comes from stdin or run it in a simple accept-loop.

The source code of socklinger is so easy and lightweight that it can be adapted to other environments easily. It has been tested under several Linux distributions and Cygwin. (Well, not each version!)

There is an example Debian installation proxy which caches all files downloaded in example/ . All you need is some machine with an Internet connection (probably a windows with Cygwin installed) and you can use the network install ISO image for your Debian. Please note that this is another step to reach my real goal: HilbiX, a 1.44 MB floppy sized console-less networked Linux install.

New features:

Options, like delay (-d).

`killall -1 socklinger` shuts down socklingers gracefully.

With -n0 (or -s) only a single accept() can be done (no looping). Options disable the old commandline behavior (prefixes n@ and src>dest).

Old features (deprecated, use commandline options):

If given socket is of form "src>dest" it is connected to. src is the address to bind to (can be empty). If @ is missing, only one single connect is done, else the connect is done in a loop (beware!).

Alternat fork method (postfork) with negative count. Default for CygWin, as accept() does not work with postfork under windows.

Future note:

It is likely that Socklinger will be merged into some other of my tools. You will read, where you then can find it. This is because I need support for non-TCP sockets, too.

CygWin note:

If socklinger does not compile under CygWin try following (do not overwrite tino/getopt.h!):

echo >getopt.h; make

This is a problem with the include chain of system headers I was unable to fix, but I don't want to "clutter" the release with a file which usually is not needed.

History:

version 2.4.0-20100126-154808

download (266574 bytes) sig

Script sockets implemented, Options -f -t -w.

All are somewhat experimental.

If the socket starts with a pipe character (|) it now is a program to execute. This allows two scripts to talk to each other, like in

socklinger -v "|bash -c 'while read a; do echo \"\$a\" >&2; done'" bash -c 'echo hello world'

Option -f is thought to change the FD on which the socket is handed to the script.

Option -t gives an upper bound to the connect timeout. This only works on connect mode.

Option -w limits the lingering to a maximum time. This is in contrast to -l which restarts on data received.

version 2.3.0-20100125-171839

download (263845 bytes) sig

Options -p and -u added for timestamping, new environment variables SOCKLINGER_NOW and SOCKLINGER_PID, now installs into /usr/local/bin

SOCKLINGER_PID is when you need to kill the outer loop for some reason, like security issues. Try following at your own risk:

#!/bin/bash
[ -n "$SOCKLINGER_PID" ] || exec env -i /usr/local/bin/socklinger -pn -5 :12345 "$0"

Also source update to latest library changes

version 2.2.0-20080422-010236

download (222823 bytes) sig

Option -r added

Postforking now even more usable with the new option -r and the two environment variables SOCKLINGER_COUNT and SOCKLINGER_MAX. This is to be able to do statistics and cleanups to notekeeping.

When forks are guaranteed to be slow (or with a high delay setting) such that there cannot be any race condition, then you can use the environment variables to do the cleanup.

On a high fork frequency you can use option -r, such that the process slots are cycled. As each slot then is visited in a round robin fashion, you can do the notekeeping (and possible cleanups) at the beginning.

version 2.1.0-20070508-054313

download (191854 bytes)

Options -q (quiet) -v (verbose) and -l (linger timeout) -m (max linger)

Now you can control the lingering process better with setting a timeout and maximum amount of data to read. The default (0:unlimited) is somewhat unsuitable for most(!) situations, however it is impossible to give a better default value. So if you have a lot of "hanging" processes in socklinger, try option -l.

version 2.0.2-20070410-142800

download (177189 bytes)

Improved alarm/delay handling (perhaps a bugfix).

The improvements are only in tinolib, but they are significant. On a very old Linux distro option -d did not work, as this platform blocks some signals. This now is compensated, as flags of used signals are now set to sane values before using them.

[view more history][view complete history]

License and Disclaimer

All you can see here is free software according to the GNU GPL.
Copyright (C)2000-2011 by Valentin Hilbig
Note that the software comes with absolutely no warranty of any kind.
You use the software at your own risk.
Valentin Hilbig cannot be hold responsible for any unintended damage,
lost data or malfunction of the software you can find here.

[FSFE contributor 2007]

[end of page - jump back to content][hacker culture]
Last modified: 2011-09-12 by Valentin Hilbig [ Imprint / Impressum ]