neulab/tldr huggingface dataset:
These options are intended for all kinds of sockets, e.g. IP or UNIX domain. Most are applied with a setsockopt() call.
bind=<sockname> Binds the socket to the given socket address using the bind() system call. The form of <sockname> is socket domain dependent: IP4 and IP6 allow the form [hostname|hostaddress][:(service|port)] (example), UNIX domain sockets require <filename>, VSOCK allow the form [cid][:(port)].
connect-timeout=<seconds> Abort the connection attempt after <seconds> [timeval] with error status.
so-bindtodevice=<interface> Binds the socket to the given <interface>.  This option might require root privilege.
broadcast For datagram sockets, allows sending to broadcast addresses and receiving packets addressed to broadcast addresses.
debug  Enables socket debugging.
dontroute Only communicates with directly connected peers, does not use routers.
keepalive Enables sending keepalives on the socket.
linger=<seconds> Blocks shutdown() or close() until data transfers have finished or the given timeout [int] expired.
oobinline Places out-of-band data in the input data stream.
priority=<priority> Sets the protocol defined <priority> [<int>] for outgoing packets.
rcvbuf=<bytes> Sets the size of the receive buffer after the socket() call to <bytes> [int].  With TCP sockets, this value corresponds to the socket’s maximal window size.
rcvbuf-late=<bytes> Sets the size of the receive buffer when the socket is already connected to <bytes> [int].  With TCP sockets, this value corresponds to the socket’s maximal window size.
rcvlowat=<bytes> Specifies the minimum number of received bytes [int] until the socket layer will pass the buffered data to socat.
reuseaddr Allows other sockets to bind to an address even if parts of it (e.g. the local port) are already in use by socat (example).
sndbuf=<bytes> Sets the size of the send buffer after the socket() call to <bytes> [int].
sndbuf-late=<bytes> Sets the size of the send buffer when the socket is connected to <bytes> [int].
sndlowat=<bytes> Specifies the minimum number of bytes in the send buffer until the socket layer will send the data to <bytes> [int].
pf=<string> Forces the use of the specified IP version or protocol. <string> can be something like "ip4" or "ip6". The resulting value is used as first argument to the socket() or socketpair() calls.  This option affects address resolution and the required syntax of bind and range options.
type=<type> Sets the type of the socket, specified as second argument to the socket() or socketpair() calls, to <type> [int]. Address resolution is not affected by this option.  Under Linux, 1 means stream oriented socket, 2 means datagram socket, and 3 means raw socket.
protocol Sets the protocol of the socket, specified as third argument to the socket() or socketpair() calls, to <protocol> [int]. Address resolution is not affected by this option.  6 means TCP, 17 means UDP.
reuseport Set the SO_REUSEPORT socket option.
so-timestamp Sets the SO_TIMESTAMP socket option. This enables receiving and logging of timestamp ancillary messages.
setsockopt=<level>:<optname>:<optval> Invokes setsockopt() for the socket with the given parameters. level [int] is used as second argument to setsockopt() and specifies the layer, e.g. SOL_TCP for TCP (6 on Linux), or SOL_SOCKET for the socket layer (1 on Linux). optname [int] is the third argument to setsockopt() and tells which socket option is to be set. For the actual numbers you might have to look up the appropriate include files of your system. For the 4th and 5th setsockopt() parameters, value [dalan] specifies an arbitrary sequence of bytes that are passed to the function per pointer, with the automatically derived length parameter.
setsockopt-int=<level>:<optname>:<optval> Like setsockopt, but <optval> is a pointer to int [int]
setsockopt-listen=<level>:<optname>:<optval> Like setsockopt, but for listen type addresses it is applied to the listening socket instead of the connected socket.
setsockopt-string=<level>:<optname>:<optval> Like setsockopt, but <optval> is a string.  This string is passed to the function with trailing null character, and the length parameter is automatically derived from the data.
UNIX option group
These options apply to UNIX domain based addresses.
unix-tightsocklen=[0|1] On socket operations, pass a socket address length that does not include the whole struct sockaddr_un record but (besides other components) only the relevant part of the filename or abstract string. Default is 1.
IP4 and IP6 option groups
These options can be used with IPv4 and IPv6 based sockets.
tos=<tos> Sets the TOS (type of service) field of outgoing packets to <tos> [byte] (see RFC 791).
ttl=<ttl> Sets the TTL (time to live) field of outgoing packets to <ttl> [byte].
ip-options=<data> Sets IP options like source routing. Must be given in binary form, recommended format is a leading "x" followed by an even number of hex digits. This option may be used multiple times, data are appended.  E.g., to connect to host 10.0.0.1 via some gateway using a loose source route, use the gateway as address parameter and set a loose source route using the option ip-options=x8307040a000001 . IP options are defined in RFC 791.
mtudiscover=<0|1|2> Takes 0, 1, 2 to never, want, or always use path MTU discover on this socket.
ip-pktinfo Sets the IP_PKTINFO socket option. This enables receiving and logging of ancillary messages containing destination address and interface (Linux) (example).
ip-recverr Sets the IP_RECVERR socket option. This enables receiving and logging of ancillary messages containing detailed error information.
ip-recvopts Sets the IP_RECVOPTS socket option. This enables receiving and logging of IP options ancillary messages (Linux, *BSD).
ip-recvtos Sets the IP_RECVTOS socket option. This enables receiving and logging of TOS (type of service) ancillary messages (Linux).
ip-recvttl Sets the IP_RECVTTL socket option. This enables receiving and logging of TTL (time to live) ancillary messages (Linux, *BSD).
ip-recvdstaddr Sets the IP_RECVDSTADDR socket option. This enables receiving and logging of ancillary messages containing destination address (*BSD) (example).
ip-recvif Sets the IP_RECVIF socket option. This enables receiving and logging of interface ancillary messages (*BSD) (example).
ip-add-membership=<multicast-address:interface-address>
ip-add-membership=<multicast-address:interface-name>
ip-add-membership=<multicast-address:interface-index>
ip-add-membership=<multicast-address:interface-address:interface-name>
ip-add-membership=<multicast-address:interface-address:interface-index> Makes the socket member of the specified multicast group. This is currently only implemented for IPv4. The option takes the IP address of the multicast group and info about the desired network interface. The most common syntax is the first one, while the others are only available on systems that provide struct mreqn (Linux). The indices of active network interfaces can be shown using the utility procan.
ip-add-source-membership=<multicast-address:interface-address:source-address> Makes the socket member of the specified multicast group for the specified source, i.e. only multicast traffic from this address is to be delivered.  This is currently only implemented for IPv4.
ip-multicast-if=<hostname> Specifies hostname or address of the network interface to be used for multicast traffic.
ip-multicast-loop=<bool> Specifies if outgoing multicast traffic should loop back to the interface.
ip-multicast-ttl=<byte> Sets the TTL used for outgoing multicast traffic. Default is 1.
ip-transparent Sets the IP_TRANSPARENT socket option.  This option might require root privilege.
res-debug
res-aaonly
res-usevc
res-primary
res-igntc
res-recurse
res-defnames
res-stayopen
res-dnsrch These options set the corresponding resolver (name resolution) option flags.  Append "=0" to clear a default option. See man resolver(5) for more information on these options. Note: these options are valid only for the address they are applied to.
IP6 option group
These options can only be used on IPv6 based sockets. See IP options for options that can be applied to both IPv4 and IPv6 sockets.
ipv6only=<bool> Sets the IPV6_V6ONLY socket option. If 0, the TCP stack will also accept connections using IPv4 protocol on the same port. The default is system dependent.
ipv6-recvdstopts Sets the IPV6_RECVDSTOPTS socket option. This enables receiving and logging of ancillary messages containing the destination options.
ipv6-recvhoplimit Sets the IPV6_RECVHOPLIMIT socket option. This enables receiving and logging of ancillary messages containing the hoplimit.
ipv6-recvhopopts Sets the IPV6_RECVHOPOPTS socket option. This enables receiving and logging of ancillary messages containing the hop options.
ipv6-recvpktinfo Sets the IPV6_RECVPKTINFO socket option. This enables receiving and logging of ancillary messages containing destination address and interface.
ipv6-unicast-hops=link(TYPE_INT)(<int>) Sets the IPV6_UNICAST_HOPS socket option. This sets the hop count limit (TTL) for outgoing unicast packets.
ipv6-recvrthdr Sets the IPV6_RECVRTHDR socket option. This enables receiving and logging of ancillary messages containing routing information.
ipv6-tclass Sets the IPV6_TCLASS socket option. This sets the transfer class of outgoing packets.
ipv6-recvtclass Sets the IPV6_RECVTCLASS socket option. This enables receiving and logging of ancillary messages containing the transfer class.
TCP option group
These options may be applied to TCP sockets. They work by invoking setsockopt() with the appropriate parameters.
cork   Doesn’t send packets smaller than MSS (maximal segment size).
defer-accept While listening, accepts connections only when data from the peer arrived.
keepcnt=<count> Sets the number of keepalives before shutting down the socket to <count> [int].
keepidle=<seconds> Sets the idle time before sending the first keepalive to <seconds> [int].
keepintvl=<seconds> Sets the interval between two keepalives to <seconds> [int].
linger2=<seconds> Sets the time to keep the socket in FIN-WAIT-2 state to <seconds> [int].
mss=<bytes> Sets the MSS (maximum segment size) after the socket() call to <bytes> [int]. This value is then proposed to the peer with the SYN or SYN/ACK packet (example).
mss-late=<bytes> Sets the MSS of the socket after connection has been established to <bytes> [int].
nodelay Turns off the Nagle algorithm for measuring the RTT (round trip time).
rfc1323 Enables RFC1323 TCP options: TCP window scale, round-trip time measurement (RTTM), and protect against wrapped sequence numbers (PAWS) (AIX).
stdurg Enables RFC1122 compliant urgent pointer handling (AIX).
syncnt=<count> Sets the maximal number of SYN retransmits during connect to <count> [int].
md5sig Enables generation of MD5 digests on the packets (FreeBSD).
noopt  Disables use of TCP options (FreeBSD, MacOSX).
nopush sets the TCP_NOPUSH socket option (FreeBSD, MacOSX).
sack-disable Disables use the selective acknowledge feature (OpenBSD).
signature-enable Enables generation of MD5 digests on the packets (OpenBSD).
abort-threshold=<milliseconds> Sets the time to wait for an answer of the peer on an established connection (HP-UX).
conn-abort-threshold=<milliseconds> Sets the time to wait for an answer of the server during the initial connect (HP-UX).
keepinit Sets the time to wait for an answer of the server during connect() before giving up. Value in half seconds, default is 150 (75s) (Tru64).
paws   Enables the "protect against wrapped sequence numbers" feature (Tru64).
sackena Enables selective acknowledge (Tru64).
tsoptena Enables the time stamp option that allows RTT recalculation on existing connections (Tru64).
UDP option group
This option may be applied to UDP datagram sockets.
udp-ignore-peerport> Address UDP-DATAGRAM expects incoming responses to come from the port specified in its second parameter. With this option, it accepts packets coming from any port.
SCTP option group
These options may be applied to SCTP stream sockets.
sctp-nodelay Sets the SCTP_NODELAY socket option that disables the Nagle algorithm.
sctp-maxseg=<bytes> Sets the SCTP_MAXSEG socket option to <bytes> [int].  This value is then proposed to the peer with the SYN or SYN/ACK packet.
UDP, TCP, and SCTP option group
Here we find options that are related to the network port mechanism and thus can be used with UDP, TCP, and SCTP client and server addresses.
sourceport=<port> For outgoing (client) TCP and UDP connections, it sets the source <port> using an extra bind() call.  With TCP or UDP listen addresses, socat immediately shuts down the connection if the client does not use this sourceport. UDP-RECV, UDP-RECVFROM, UDP-SENDTO, and UDP-DATAGRAM addresses ignore the packet when it does not match.  (example).
lowport Outgoing (client) TCP and UDP connections with this option use an unused random source port between 640 and 1023 incl. On UNIX class operating systems, this requires root privilege, and thus indicates that the client process is authorized by local root. TCP and UDP listen addresses with this option immediately shut down the connection if the client does not use a sourceport <= 1023.  This mechanism can provide limited authorization under some circumstances.
SOCKS option group
When using SOCKS type addresses, some socks specific options can be set.
socksport=<tcp service> Overrides the default "socks" service or port 1080 for the socks server port with <TCP service>.
socksuser=<user> Sends the <user> [string] in the username field to the socks server. Default is the actual user name ($LOGNAME or $USER) (example).
HTTP option group
Options that can be provided with HTTP type addresses. The only HTTP address currently implemented is proxy-connect.
proxyport=<TCP service> Overrides the default HTTP proxy port 8080 with <TCP service>.
ignorecr The HTTP protocol requires the use of CR+NL as line terminator. When a proxy server violates this standard, socat might not understand its answer.  This option directs socat to interprete NL as line terminator and to ignore CR in the answer. Nevertheless, socat sends CR+NL to the proxy.
proxy-authorization=<username>:<password> Provide "basic" authentication to the proxy server. The argument to the option is used with a "Proxy-Authorization: Basic" header in base64 encoded form. Note: username and password are visible for every user on the local machine in the process list; username and password are transferred to the proxy server unencrypted (base64 encoded) and might be sniffed.
proxy-authorization-file=<filename> Like option proxy-authorization, but the credentials are read from the file and therefore not visible in the process list.
resolve Per default, socat sends to the proxy a CONNECT request containing the target hostname. With this option, socat resolves the hostname locally and sends the IP address. Please note that, according to RFC 2396, only name resolution to IPv4 addresses is implemented.
RANGE option group
These options check if a connecting client should be granted access. They can be applied to listening and receiving network sockets. tcp-wrappers options fall into this group.
range=<address-range> After accepting a connection, tests if the peer is within range. For IPv4 addresses, address-range takes the form address/bits, e.g.  10.0.0.0/8, or address:mask, e.g. 10.0.0.0:255.0.0.0 (example); for IPv6, it is [ip6-address]/bits, e.g. [::1]/128.  If the client address does not match, socat refuses the connection attempt, issues a warning, and keeps listening/receiving.
tcpwrap[=<name>] Uses Wietse Venema’s libwrap (tcpd) library to determine if the client is allowed to connect. The configuration files are /etc/hosts.allow and /etc/hosts.deny per default, see "man 5 hosts_access" for more information. The optional <name> (type string) is passed to the wrapper functions as daemon process name (example).  If omitted, the basename of socats invocation (argv[0]) is passed.  If both tcpwrap and range options are applied to an address, both conditions must be fulfilled to allow the connection.
allow-table=<filename> Takes the specified file instead of /etc/hosts.allow.
deny-table=<filename> Takes the specified file instead of /etc/hosts.deny.
tcpwrap-etc=<directoryname> Looks for hosts.allow and hosts.deny in the specified directory. Is overridden by options hosts-allow and hosts-deny.
LISTEN option group
Options specific to listening sockets.
backlog=<count> Sets the backlog value passed with the listen() system call to <count> [int]. Default is 5.
accept-timeout=<seconds> End waiting for a connection after <seconds> [timeval] with error status.
max-children=<count> Limits the number of concurrent child processes [int].  Default is no limit.
CHILD option group
Options for addresses with multiple connections via child processes.
fork   After establishing a connection, handles its channel in a child process and keeps the parent process attempting to produce more connections, either by listening or by connecting in a loop (example). OPENSSL-CONNECT and OPENSSL-LISTEN differ in when they actually fork off the child: OPENSSL-LISTEN forks before the SSL handshake, while OPENSSL-CONNECT forks afterwards.  retry and forever options are not inherited by the child process. On some operating systems (e.g. FreeBSD) this option does not work for UDP-LISTEN addresses.
EXEC option group
Options for addresses that invoke a program.
path=<string> Overrides the PATH environment variable for searching the program with <string>. This $PATH value is effective in the child process too.
login  Prefixes argv[0] for the execvp() call with ’-’, thus making a shell behave as login shell.
FORK option group
EXEC or SYSTEM addresses invoke a program using a child process and transfer data between socat and the program. The interprocess communication mechanism can be influenced with the following options. Per default, a socketpair() is created and assigned to stdin and stdout of the child process, while stderr is inherited from the socat process, and the child process uses file descriptors 0 and 1 for communicating with the main socat process.
nofork Does not fork a subprocess for executing the program, instead calls execvp() or system() directly from the actual socat instance. This avoids the overhead of another process between the program and its peer, but introduces a lot of restrictions:
o      this option can only be applied to the second socat address.
o      it cannot be applied to a part of a dual address.
o      the first socat address cannot be OPENSSL or READLINE
o      socat options -b, -t, -D, -l, -v, -x become useless
o      for both addresses, options ignoreeof, cr, and crnl become useless
o      for the second address (the one with option nofork), options append,  cloexec, flock, user, group, mode, nonblock, perm-late, setlk, and setpgid cannot be applied. Some of these could be used on the first address though.
pipes  Creates a pair of unnamed pipes for interprocess communication instead of a socket pair.
openpty Establishes communication with the sub process using a pseudo terminal created with openpty() instead of the default (socketpair or ptmx).
ptmx   Establishes communication with the sub process using a pseudo terminal created by opening /dev/ptmx or /dev/ptc instead of the default (socketpair).
pty    Establishes communication with the sub process using a pseudo terminal instead of a socket pair. Creates the pty with an available mechanism. If openpty and ptmx are both available, it uses ptmx because this is POSIX compliant (example).
ctty   Makes the pty the controlling tty of the sub process (example).
stderr Directs stderr of the sub process to its output channel by making stderr a dup() of stdout (example).
fdin=<fdnum> Assigns the sub processes input channel to its file descriptor <fdnum> instead of stdin (0). The program started from the subprocess has to use this fd for reading data from socat (example).
fdout=<fdnum> Assigns the sub processes output channel to its file descriptor <fdnum> instead of stdout (1). The program started from the subprocess has to use this fd for writing data to socat (example).
sighup, sigint, sigquit Has socat pass signals of this type to the sub process.  If no address has this option, socat terminates on these signals.
TERMIOS option group
For addresses that work on a tty (e.g., stdio, file:/dev/tty, exec:...,pty), the terminal parameters defined in the UN*X termios mechanism are made available as address option parameters.  Please note that changes of the parameters of your interactive terminal remain effective after socat’s termination, so you might have to enter "reset" or "stty sane" in your shell afterwards.  For EXEC and SYSTEM addresses with option PTY, these options apply to the pty by the child processes.
b0     Disconnects the terminal.
b19200 Sets the serial line speed to 19200 baud. Some other rates are possible; use something like socat -hh |grep ’ b[1-9]’ to find all speeds supported by your implementation. Note: On some operating systems, these options may not be available. Use ispeed or ospeed instead.
echo=<bool> Enables or disables local echo.
icanon=<bool> Sets or clears canonical mode, enabling line buffering and some special characters.
raw    Sets raw mode, thus passing input and output almost unprocessed. This option is obsolete, use option rawer or cfmakeraw instead.
rawer  Makes terminal rawer than raw option. This option implicitly turns off echo. (example).
cfmakeraw Sets raw mode by invoking cfmakeraw() or by simulating this call. This option implicitly turns off echo.
ignbrk=<bool> Ignores or interpretes the BREAK character (e.g., ^C)
brkint=<bool>
bsdly=<0|1>
clocal=<bool>
cr0 cr1 cr2 cr3
Sets the carriage return delay to 0, 1, 2, or 3, respectively.  0 means no delay, the other values are terminal dependent.
crdly=<0|1|2|3>
cread=<bool>
crtscts=<bool>
cs5 cs6 cs7 cs8
Sets the character size to 5, 6, 7, or 8 bits, respectively.
csize=<0|1|2|3>
cstopb=<bool> Sets two stop bits, rather than one.
dsusp=<byte> Sets the value for the VDSUSP character that suspends the current foreground process and reactivates the shell (all except Linux).
echoctl=<bool> Echos control characters in hat notation (e.g. ^A)
echoe=<bool>
echok=<bool>
echoke=<bool>
echonl=<bool>
echoprt=<bool>
eof=<byte>
eol=<byte>
eol2=<byte>
erase=<byte>
discard=<byte>
ff0
ffdly=<bool>
flusho=<bool>
hupcl=<bool>
icrnl=<bool>
iexten=<bool>
igncr=<bool>
ignpar=<bool>
imaxbel=<bool>
inlcr=<bool>
inpck=<bool>
intr=<byte>
isig=<bool>
ispeed=<unsigned-int> Set the baud rate for incoming data on this line. See also: ospeed, b19200
istrip=<bool>
iuclc=<bool>
ixany=<bool>
ixoff=<bool>
ixon=<bool>
kill=<byte>
lnext=<byte>
min=<byte>
nl0    Sets the newline delay to 0.
nl1
nldly=<bool>
noflsh=<bool>
ocrnl=<bool>
ofdel=<bool>
ofill=<bool>
olcuc=<bool>
onlcr=<bool>
onlret=<bool>
onocr=<bool>
opost=<bool> Enables or disables output processing; e.g., converts NL to CR-NL.
ospeed=<unsigned-int> Set the baud rate for outgoing data on this line. See also: ispeed, b19200
parenb=<bool> Enable parity generation on output and parity checking for input.
parmrk=<bool>
parodd=<bool>
pendin=<bool>
quit=<byte>
reprint=<byte>
sane   Brings the terminal to something like a useful default state.
start=<byte>
stop=<byte>
susp=<byte>
swtc=<byte>
tab0
tabdly=<unsigned-int>
time=<byte>
tostop=<bool>
vt0
vt1
vtdly=<bool>
werase=<byte>
xcase=<bool>
xtabs
i-pop-all With UNIX System V STREAMS, removes all drivers from the stack.
i-push=<string> With UNIX System V STREAMS, pushes the driver (module) with the given name (string) onto the stack. For example, to make sure that a character device on Solaris supports termios etc, use the following options: i-pop-all,i-push=ptem,i-push=ldterm,i-push=ttcompat
PTY option group
These options are intended for use with the pty address type.
link=<filename> Generates a symbolic link that points to the actual pseudo terminal (pty). This might help to solve the problem that ptys are generated with more or less unpredictable names, making it difficult to directly access the socat generated pty automatically. With this option, the user can specify a "fix" point in the file hierarchy that helps him to access the actual pty (example).  Beginning with socat version 1.4.3, the symbolic link is removed when the address is closed (but see option unlink-close).
wait-slave Blocks the open phase until a process opens the slave side of the pty.  Usually, socat continues after generating the pty with opening the next address or with entering the transfer loop. With the wait-slave option, socat waits until some process opens the slave side of the pty before continuing.  This option only works if the operating system provides the poll() system call. And it depends on an undocumented behaviour of pty’s, so it does not work on all operating systems. It has successfully been tested on Linux, FreeBSD, NetBSD, and on Tru64 with openpty.
pty-interval=<seconds> When the wait-slave option is set, socat periodically checks the HUP condition using poll() to find if the pty’s slave side has been opened. The default polling interval is 1s. Use the pty-interval option [timeval] to change this value.
OPENSSL option group
These options apply to the openssl and openssl-listen address types.
cipher=<cipherlist> Selects the list of ciphers that may be used for the connection. See the man page of ciphers , section CIPHER LIST FORMAT, for detailed information about syntax, values, and default of <cipherlist>. Several cipher strings may be given, separated by ’:’.  Some simple cipher strings:
3DES   Uses a cipher suite with triple DES.
MD5    Uses a cipher suite with MD5.
aNULL  Uses a cipher suite without authentication.
NULL   Does not use encryption.
HIGH   Uses a cipher suite with "high" encryption.  Note that the peer must support the selected property, or the negotiation will fail.
method=<ssl-method> This option is based on deprecated functions and is only available when socat was build with option --with-openssl-method.  Sets the protocol version to be used. Valid strings (not case sensitive) are:
SSL2   Select SSL protocol version 2.
SSL3   Select SSL protocol version 3.
SSL23  Select the best available SSL or TLS protocol.
TLS1   Select TLS protocol version 1.
TLS1.1 Select TLS protocol version 1.1.
TLS1.2 Select TLS protocol version 1.2.  When this option is not provided OpenSSL negotiates the mothod with its peer.
verify=<bool> Controls check of the peer’s certificate. Default is 1 (true). Disabling verify might open your socket for everyone, making the encryption useless!
cert=<filename> Specifies the file with the certificate and private key for authentication.  The certificate must be in OpenSSL format (*.pem).  With openssl-listen, use of this option is strongly recommended. Except with cipher aNULL, "no shared ciphers" error will occur when no certificate is given.
key=<filename> Specifies the file with the private key. The private key may be in this file or in the file given with the cert option. The party that has to proof that it is the owner of a certificate needs the private key.
dhparams=<filename> Specifies the file with the Diffie Hellman parameters. These parameters may also be in the file given with the cert option in which case the dhparams option is not needed.
cafile=<filename> Specifies the file with the trusted (root) authority certificates. The file must be in PEM format and should contain one or more certificates. The party that checks the authentication of its peer trusts only certificates that are in this file.
capath=<dirname> Specifies the directory with the trusted (root) certificates. The directory must contain certificates in PEM format and their hashes (see OpenSSL documentation)
egd=<filename> On some systems, openssl requires an explicit source of random data. Specify the socket name where an entropy gathering daemon like egd provides random data, e.g. /dev/egd-pool.
pseudo On systems where openssl cannot find an entropy source and where no entropy gathering daemon can be utilized, this option activates a mechanism for providing pseudo entropy. This is achieved by taking the current time in microseconds for feeding the libc pseudo random number generator with an initial value. openssl is then feeded with output from random() calls. NOTE:This mechanism is not sufficient for generation of secure keys!
compress Enable or disable the use of compression for a connection. Setting this to "none" disables compression, setting it to "auto" lets OpenSSL choose the best available algorithm supported by both parties. The default is to not touch any compression-related settings.  NOTE: Requires OpenSSL 0.9.8 or higher and disabling compression with OpenSSL 0.9.8 affects all new connections in the process.
commonname=<string> Specify the commonname that the peer certificate must match. With OPENSSL-CONNECT address this overrides the given hostname or IP target address; with OPENSSL-LISTEN this turns on check of peer certificates commonname. This option has only meaning when option verify is not disabled and the chosen cipher provides a peer certificate.
no-sni=<bool> Do not use the client side Server Name Indication (SNI) feature that selects the desired server certificate. Note: SNI is automatically used since socat version 1.7.4.0 and uses commonname or the given host name.
snihost=<string> Set the client side Server Name Indication (SNI) host name different from the addressed server name or common name. This might be useful when the server certificate has multiple host names or wildcard names because the SNI host name is passed in cleartext to the server and might be eavesdropped; with this option a mock name of the desired certificate may be transferred.
fips   Enables FIPS mode if compiled in. For info about the FIPS encryption implementation standard see http://oss-institute.org/fips-faq.html.  This mode might require that the involved certificates are generated with a FIPS enabled version of openssl. Setting or clearing this option on one socat address affects all OpenSSL addresses of this process.
RETRY option group
Options that control retry of some system calls, especially connection attempts.
retry=<num> Number of retries before the connection or listen attempt is aborted.  Default is 0, which means just one attempt.
interval=<timespec> Time between consecutive attempts (seconds, [timespec]). Default is 1 second.
forever Performs an unlimited number of retry attempts.
TUN option group
Options that control Linux TUN/TAP interface device addresses.
tun-device=<device-file> Instructs socat to take another path for the TUN clone device. Default is /dev/net/tun.
tun-name=<if-name> Gives the resulting network interface a specific name instead of the system generated (tun0, tun1, etc.)
tun-type=[tun|tap] Sets the type of the TUN device; use this option to generate a TAP device. See the Linux docu for the difference between these types. When you try to establish a tunnel between two TUN devices, their types should be the same.
iff-no-pi Sets the IFF_NO_PI flag which controls if the device includes additional packet information in the tunnel.  When you try to establish a tunnel between two TUN devices, these flags should have the same values.
iff-up Sets the TUN network interface status UP. Strongly recommended.
iff-broadcast Sets the BROADCAST flag of the TUN network interface.
iff-debug Sets the DEBUG flag of the TUN network interface.
iff-loopback Sets the LOOPBACK flag of the TUN network interface.
iff-pointopoint Sets the POINTOPOINT flag of the TUN device.
iff-notrailers Sets the NOTRAILERS flag of the TUN device.
iff-running Sets the RUNNING flag of the TUN device.
iff-noarp Sets the NOARP flag of the TUN device.
iff-promisc Sets the PROMISC flag of the TUN device.
iff-allmulti Sets the ALLMULTI flag of the TUN device.
iff-master Sets the MASTER flag of the TUN device.
iff-slave Sets the SLAVE flag of the TUN device.
iff-multicast Sets the MULTICAST flag of the TUN device.
iff-portsel Sets the PORTSEL flag of the TUN device.
iff-automedia Sets the AUTOMEDIA flag of the TUN device.
iff-dynamic Sets the DYNAMIC flag of the TUN device.
This section explains the different data types that address parameters and address options can take.
address-range Is currently only implemented for IPv4 and IPv6. See address-option `range’
bool   "0" or "1"; if value is omitted, "1" is taken.
byte   An unsigned int number, read with strtoul() , lower or equal to UCHAR_MAX .
command-line A string specifying a program name and its arguments, separated by single spaces.
data   This is a more general data specification. The given text string contains information about the target data type and value. Generally a leading character specifies the type of the following data item. In its specific context a default data type may exist. Currently only the following specifications are implemented:
i      A signed integer number, stored in host byte order. Example:    i-1000    (Integer number -1000)
I      An unsigned integer number, stored in host byte order.
l      A signed long integer number, stored in host byte order.
L      An unsigned long integer number, stored in host byte order.
s      A signed short integer number, stored in host byte order.
S      An unsigned short integer number, stored in host byte order.
b      A signed byte (signed char).
B      An unsigned byte (unsigned char).
x      Following is an even number of hex digits, stored as sequence of bytes. Example:    x7f000001 (IP address 127.0.0.1)
"      Following is a string that is used with the common conversions \n \r \t \f \b \a \e \0; the string must be closed with ’"’. Please note that the quotes and backslashes need to be escaped from shell and socat conversion. Example:    "Hello world!\n"
’      A single char, with the usual conversions. Please note that the quotes and backslashes need to be escaped from shell and socat conversion. Example:    ’a’ Data items may be separated with white space without need to repeat the type specifier again.
directory A string with usual UN*X directory name semantics.
facility The name of a syslog facility in lower case characters.
fdnum  An unsigned int type, read with strtoul() , specifying a UN*X file descriptor.
filename A string with usual UN*X filename semantics.
group  If the first character is a decimal digit, the value is read with strtoul() as unsigned integer specifying a group id. Otherwise, it must be an existing group name.
int    A number following the rules of the strtol() function with base "0", i.e. decimal number, octal number with leading "0", or hexadecimal number with leading "0x". The value must fit into a C int.
interface A string specifying the device name of a network interface as shown by ifconfig or procan, e.g. "eth0".
IP address An IPv4 address in numbers-and-dots notation, an IPv6 address in hex notation enclosed in brackets, or a hostname that resolves to an IPv4 or an IPv6 address. Examples: 127.0.0.1, [::1], www.dest-unreach.org, dns1
IPv4 address An IPv4 address in numbers-and-dots notation or a hostname that resolves to an IPv4 address. Examples: 127.0.0.1, www.dest-unreach.org, dns2
IPv6 address An IPv6 address in hexnumbers-and-colons notation enclosed in brackets, or a hostname that resolves to an IPv6 address. Examples: [::1], [1234:5678:9abc:def0:1234:5678:9abc:def0], ip6name.domain.org
long   A number read with strtol() . The value must fit into a C long.
long long A number read with strtoll() . The value must fit into a C long long.
off_t  An implementation dependend signed number, usually 32 bits, read with strtol or strtoll.
off64_t An implementation dependend signed number, usually 64 bits, read with strtol or strtoll.
mode_t An unsigned integer, read with strtoul() , specifying mode (permission) bits.
pid_t  A number, read with strtol() , specifying a process id.
port   A uint16_t (16 bit unsigned number) specifying a TCP or UDP port, read with strtoul() .
protocol An unsigned 8 bit number, read with strtoul() .
size_t An unsigned number with size_t limitations, read with strtoul .
sockname A socket address. See address-option `bind’
string A sequence of characters, not containing ’\0’ and, depending on the position within the command line, ’:’, ’,’, or "!!". Note that you might have to escape shell meta characters in the command line.
TCP service A service name, not starting with a digit, that is resolved by getservbyname() , or an unsigned int 16 bit number read with strtoul() .
timeval A double float specifying seconds; the number is mapped into a struct timeval, consisting of seconds and microseconds.
timespec A double float specifying seconds; the number is mapped into a struct timespec, consisting of seconds and nanoseconds.
UDP service A service name, not starting with a digit, that is resolved by getservbyname() , or an unsigned int 16 bit number read with strtoul() .
unsigned int A number read with strtoul() . The value must fit into a C unsigned int.
user   If the first character is a decimal digit, the value is read with strtoul() as unsigned integer specifying a user id. Otherwise, it must be an existing user name.
VSOCK cid A uint32_t (32 bit unsigned number) specifying a VSOCK Context Identifier (CID), read with strtoul() .  There are several special addresses: VMADDR_CID_ANY (-1U) means any address for binding; VMADDR_CID_HOST (2) is the well-known address of the host.
VSOCK port A uint32_t (32 bit unsigned number) specifying a VSOCK port, read with strtoul() .
socat - TCP4:www.domain.org:80
transfers data between STDIO (-) and a TCP4 connection to port 80 of host www.domain.org. This example results in an interactive connection similar to telnet or netcat. The stdin terminal parameters are not changed, so you may close the relay with ^D or abort it with ^C.
socat -d -d READLINE,history=$HOME/.http_history \ TCP4:www.domain.org:www,crnl
this is similar to the previous example, but you can edit the current line in a bash like manner (READLINE) and use the history file .http_history; socat prints messages about progress (-d -d). The  port is specified by service name (www), and correct network line termination characters (crnl) instead of NL are used.
socat TCP4-LISTEN:www TCP4:www.domain.org:www
installs a simple TCP port forwarder. With TCP4-LISTEN it listens on local port "www" until a connection comes in, accepts it, then connects to the remote host (TCP4) and starts data transfer. It will not accept a second connection.
socat -d -d -lmlocal2 \ TCP4-LISTEN:80,bind=myaddr1,reuseaddr,fork,su=nobody,range=10.0.0.0/8 \ TCP4:www.domain.org:80,bind=myaddr2
TCP port forwarder, each side bound to another local IP address (bind). This example handles an almost arbitrary number of parallel or consecutive connections by fork’ing a new process after each accept() . It provides a little security by su’ing to user nobody after forking; it only permits connections from the private 10 network (range); due to reuseaddr, it allows immediate restart after master process’s termination, even if some child sockets are not completely shut down.  With -lmlocal2, socat logs to stderr until successfully reaching the accept loop. Further logging is directed to syslog with facility local2.
socat TCP4-LISTEN:5555,fork,tcpwrap=script \ EXEC:/bin/myscript,chroot=/home/sandbox,su-d=sandbox,pty,stderr
a simple server that accepts connections (TCP4-LISTEN) and fork’s a new child process for each connection; every child acts as single relay.  The client must match the rules for daemon process name "script" in /etc/hosts.allow and /etc/hosts.deny, otherwise it is refused access (see "man 5 hosts_access").  For EXEC’uting the program, the child process chroot’s to /home/sandbox, su’s to user sandbox, and then starts the program /home/sandbox/bin/myscript. Socat and myscript communicate via a pseudo tty (pty); myscript’s stderr is redirected to stdout, so its error messages are transferred via socat to the connected client.
socat EXEC:"mail.sh target@domain.com",fdin=3,fdout=4 \ TCP4:mail.relay.org:25,crnl,bind=alias1.server.org,mss=512
mail.sh is a shell script, distributed with socat, that implements a simple SMTP client. It is programmed to "speak" SMTP on its FDs 3 (in) and 4 (out).  The fdin and fdout options tell socat to use these FDs for communication with the program. Because mail.sh inherits stdin and stdout while socat does not use them, the script can read a mail body from stdin. Socat makes alias1 your local source address (bind), cares for correct network line termination (crnl) and sends at most 512 data bytes per packet (mss).
socat -,escape=0x0f /dev/ttyS0,rawer,crnl
opens an interactive connection via the serial line, e.g. for talking with a modem. rawer sets the console’s and ttyS0’s terminal parameters to practicable values, crnl converts to correct newline characters. escape allows terminating the socat process with character control-O.  Consider using READLINE instead of the first address.
socat UNIX-LISTEN:/tmp/.X11-unix/X1,fork \ SOCKS4:host.victim.org:127.0.0.1:6000,socksuser=nobody,sourceport=20
with UNIX-LISTEN, socat opens a listening UNIX domain socket /tmp/.X11-unix/X1. This path corresponds to local XWindow display :1 on your machine, so XWindow client connections to DISPLAY=:1 are accepted. Socat then speaks with the SOCKS4 server host.victim.org that might permit sourceport 20 based connections due to an FTP related weakness in its static IP filters. Socat pretends to be invoked by socksuser nobody, and requests to be connected to loopback port 6000 (only weak sockd configurations will allow this). So we get a connection to the victims XWindow server and, if it does not require MIT cookies or Kerberos authentication, we can start work. Please note that there can only be one connection at a time, because TCP can establish only one session with a given set of addresses and ports.
socat -u /tmp/readdata,seek-end=0,ignoreeof -
this is an example for unidirectional data transfer (-u). Socat transfers data from file /tmp/readdata (implicit address GOPEN), starting at its current end (seek-end=0 lets socat start reading at current end of file; use seek=0 or no seek option to first read the existing data) in a "tail -f" like mode (ignoreeof). The "file" might also be a listening UNIX domain socket (do not use a seek option then).
(sleep 5; echo PASSWORD; sleep 5; echo ls; sleep 1) | socat - EXEC:'ssh -l user server',pty,setsid,ctty
EXEC’utes an ssh session to server. Uses a pty for communication between socat and ssh, makes it ssh’s controlling tty (ctty), and makes this pty the owner of a new process group (setsid), so ssh accepts the password from socat.
socat -u TCP4-LISTEN:3334,reuseaddr,fork \ OPEN:/tmp/in.log,creat,append
implements a simple network based message collector.  For each client connecting to port 3334, a new child process is generated (option fork).  All data sent by the clients are append’ed to the file /tmp/in.log.  If the file does not exist, socat creat’s it. Option reuseaddr allows immediate restart of the server process.
socat READLINE,noecho=’[Pp]assword:’ EXEC:’ftp ftp.server.com’,pty,setsid,ctty
wraps a command line history (READLINE) around the EXEC’uted ftp client utility.  This allows editing and reuse of FTP commands for relatively comfortable browsing through the ftp directory hierarchy. The password is echoed!  pty is required to have ftp issue a prompt.  Nevertheless, there may occur some confusion with the password and FTP prompts.
socat PTY,link=$HOME/dev/vmodem0,rawer,wait-slave \ EXEC:"ssh modemserver.us.org socat - /dev/ttyS0,nonblock,rawer"
generates a pseudo terminal device (PTY) on the client that can be reached under the symbolic link $HOME/dev/vmodem0.  An application that expects a serial line or modem can be configured to use $HOME/dev/vmodem0; its traffic will be directed to a modemserver via ssh where another socat instance links it to /dev/ttyS0.
socat TCP4-LISTEN:2022,reuseaddr,fork \ PROXY:proxy:www.domain.org:22,proxyport=3128,proxyauth=user:pass
starts a forwarder that accepts connections on port 2022, and directs them through the proxy daemon listening on port 3128 (proxyport) on host proxy, using the CONNECT method, where they are authenticated as "user" with "pass" (proxyauth). The proxy should establish connections to host www.domain.org on port 22 then.
socat - SSL:server:4443,cafile=server.crt,cert=client.pem
is an OpenSSL client that tries to establish a secure connection to an SSL server. Option cafile specifies a file that contains trust certificates: we trust the server only when it presents one of these certificates and proofs that it owns the related private key.  Otherwise the connection is terminated.  With cert a file containing the client certificate and the associated private key is specified. This is required in case the server wishes a client authentication; many Internet servers do not. The first address (’-’) can be replaced by almost any other socat address.
socat OPENSSL-LISTEN:4443,reuseaddr,pf=ip4,fork,cert=server.pem,cafile=client.crt PIPE
is an OpenSSL server that accepts TCP connections, presents the certificate from the file server.pem and forces the client to present a certificate that is verified against cafile.crt. The second address (’PIPE’) can be replaced by almost any other socat address. For instructions on generating and distributing OpenSSL keys and certificates see the additional socat docu socat-openssl.txt.
echo |socat -u - file:/tmp/bigfile,create,largefile,seek=100000000000
creates a 100GB sparse file; this requires a file system type that supports this (ext2, ext3, reiserfs, jfs; not minix, vfat). The operation of writing 1 byte might take long (reiserfs: some minutes; ext2: "no" time), and the resulting file can consume some disk space with just its inodes (reiserfs: 2MB; ext2: 16KB).
socat tcp-l:7777,reuseaddr,fork system:’filan -i 0 -s >&2’,nofork
listens for incoming TCP connections on port 7777. For each accepted connection, invokes a shell. This shell has its stdin and stdout directly connected to the TCP socket (nofork).  The shell starts filan and lets it print the socket addresses to stderr (your terminal window).
echo -e "\0\14\0\0\c" |socat -u - file:/usr/bin/squid.exe,seek=0x00074420
functions as primitive binary editor: it writes the 4 bytes 000 014 000 000 to the executable /usr/bin/squid at offset 0x00074420 (this is a real world patch to make the squid executable from Cygwin run under Windows, actual per May 2004).
socat - tcp:www.blackhat.org:31337,readbytes=1000
connects to an unknown service and prevents being flooded.
socat -U TCP:target:9999,end-close TCP-L:8888,reuseaddr,fork
merges data arriving from different TCP streams on port 8888 to just one stream to target:9999. The end-close option prevents the child processes forked off by the second address from terminating the shared connection to 9999 (close(2) just unlinks the inode which stays active as long as the parent process lives; shutdown(2) would actively terminate the connection).
socat - UDP4-DATAGRAM:192.168.1.0:123,sp=123,broadcast,range=192.168.1.0/24
sends a broadcast to the network 192.168.1.0/24 and receives the replies of the timeservers there. Ignores NTP packets from hosts outside this network.
socat - SOCKET-DATAGRAM:2:2:17:x007bxc0a80100x0000000000000000,bind=x007bx00000000x0000000000000000,setsockopt-int=1:6:1,range=x0000xc0a80100x0000000000000000:x0000xffffff00x0000000000000000
is semantically equivalent to the previous example, but all parameters are specified in generic form. the value 6 of setsockopt-int is the Linux value for SO_BROADCAST.
socat - IP4-DATAGRAM:255.255.255.255:44,broadcast,range=10.0.0.0/8
sends a broadcast to the local network(s) using protocol 44. Accepts replies from the private address range only.
socat - UDP4-DATAGRAM:224.255.0.1:6666,bind=:6666,ip-add-membership=224.255.0.1:eth0
transfers data from stdin to the specified multicast address using UDP. Both local and remote ports are 6666. Tells the interface eth0 to also accept multicast packets of the given group. Multiple hosts on the local network can run this command, so all data sent by any of the hosts will be received by all the other ones. Note that there are many possible reasons for failure, including IP-filters, routing issues, wrong interface selection by the operating system, bridges, or a badly configured switch.
socat UDP:host2:4443 TUN:192.168.255.1/24,up
establishes one side of a virtual (but not private!) network with host2 where a similar process might run, with UDP-L and tun address 192.168.255.2. They can reach each other using the addresses 192.168.255.1 and 192.168.255.2. Note that streaming eg.via TCP or SSL does not guarantee to retain packet boundaries and might thus cause packet loss.
socat - VSOCK-CONNECT:2:1234