Execute quick hack shell scripts connected to a socket. # $Header: /CVSROOT/socklinger/DESCRIPTION,v 1.7 2007-04-04 03:44:44 tino Exp $ # # $Log: DESCRIPTION,v $ # Revision 1.7 2007-04-04 03:44:44 tino # Preparing next dist # # Revision 1.6 2007/03/27 01:13:12 tino # Prepared for new dist # # Revision 1.5 2006/12/12 11:52:17 tino # New version with editing in the old edits to do prefork and connect # # Revision 1.4 2006/01/25 03:31:13 tino # dist 1.3.1 # # Revision 1.3 2005/03/15 18:28:05 tino # only text reformatted with emacs # # Revision 1.2 2004/09/20 01:20:05 tino # published # # Revision 1.1 2004/08/16 01:29:57 Administrator # initial add 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; makeThis 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.