Programs ... SockOpts

General

SockOpts is a program I wrote for setting some defaults for all sockets you open.

It all started as a simple program that would help you bind to a specific address for all connections by default. It is useful especially for outgoing connections where you can choose one of the many ip addresses an interface can have, or route all packets through a certain interface.

Technical information

I will add more technical information later.

The program is written in C. At the tarball you can also find a Makefile.

Usage

$ export LD_PRELOAD=/path/to/sockopts.so
$ export SOCKOPTS_BIND_ADDR=10.0.0.1
$ SOCKOPTS_OPT_KEEPALIVE=1 nc www.google.com 80
        

You must first use the environment LD_PRELOAD to instruct the runtime linker to preload your library. Then you can set any of the following environment variables to bind to an address/interface or to set any socket options you want.

The descriptions for the socket options are taken from the socket(7) man page.

Download

The program is available for download here.

License

The program is licensed under the terms of the MIT license.