.TH "socat" "1" "September 2005" "socat" ""
.PP
.PP
.SH "NAME"
socat \- Multipurpose relay (SOcket CAT)
.PP
.SH "SYNOPSIS"
\f(CWsocat [options]
\fP
.br
\f(CWsocat -V\fP
.br
\f(CWsocat -h[h[h]] | -?[?[?]]\fP
.br
\f(CWfilan\fP
.br
\f(CWprocan\fP
.PP
.SH "DESCRIPTION"
.PP
\fBSocat\fP is a command line based utility that establishes two bidirectional byte
streams and transfers data between them\&. Because the streams can be constructed
from a large set of different types of data sinks and sources
(see address types), and because lots of
address options may be applied to the streams, socat can
be used for many different purposes\&.
It might be one of the tools that one `has already needed\'\&.
.PP
\fBFilan\fP is a utility that prints information about its active file
descriptors to stdout\&. It has been written for debugging \fBsocat\fP, but might be
useful for other purposes too\&. Use the -h option to find more infos\&.
.PP
\fBProcan\fP is a utility that prints information about process parameters to
stdout\&. It has been written to better understand
some UNIX process properties and for debugging \fBsocat\fP, but might be
useful for other purposes too\&.
.PP
The life cycle of a \fBsocat\fP instance typically consists of four phases\&.
.PP
In the \fIinit\fP phase, the command line options are parsed and logging is
initialized\&.
.PP
During the \fIopen\fP phase, \fBsocat\fP opens the first address and afterwards the
second address\&. These steps are usually blocking; thus, for complex address types like socks,
connection requests or authentication dialogs must be completed before the next
step is started\&.
.PP
In the \fItransfer\fP phase, \fBsocat\fP watches both streams\' read and write file
descriptors via \f(CWselect()\fP, and, when data is available on one side \fIand\fP
can be written to the other side, socat reads it, performs newline
character conversions if required, and writes the data to the write file
descriptor of the other stream, then continues waiting for more data in both
directions\&.
.PP
When one of the streams effectively reaches EOF, the \fIclosing\fP phase
begins\&. \fBSocat\fP transfers the EOF condition to the other stream,
i\&.e\&. tries to shutdown only its write stream, thus giving it a chance to
terminate gracefully\&. For a defined time, \fBsocat\fP continues to transfer data in
the other direction, but then closes all remaining channels and terminates\&.
.PP
.SH "OPTIONS"
.PP
\fBSocat\fP provides some command line options that modify the behaviour of the
program\&. They have nothing to do with so called
address options that are used as parts of address specifications\&.
.PP
.IP "\fB\f(CW-V\fP\fP"
Print version and available feature information to stdout, and exit\&.
.IP "\fB\f(CW-h | -?\fP\fP"
Print a help text to stdout describing command line options and available address
types, and exit\&.
.IP "\fB\f(CW-hh | -??\fP\fP"
Like -h, plus a list of the short names of all available address options\&. Some options are
platform dependend, so this output is helpful for checking the particular
implementation\&.
.IP "\fB\f(CW-hhh | -???\fP\fP"
Like -hh, plus a list of all available address option names\&.
.IP "\fB\f(CW-d\fP\fP"
Without this option, only fatal and error messages are generated; applying
this option also prints warning messages\&. See DIAGNOSTICS
for more information\&.
.IP "\fB\f(CW-d -d\fP\fP"
Prints fatal, error, warning, and notice messages\&.
.IP "\fB\f(CW-d -d -d\fP\fP"
Prints fatal, error, warning, notice, and info messages\&.
.IP "\fB\f(CW-d -d -d -d\fP\fP"
Prints fatal, error, warning, notice, info, and debug
messages\&.
.IP "\fB\f(CW-D\fP\fP"
Logs information about file descriptors before starting the transfer phase\&.
.IP "\fB\f(CW-ly[]\fP\fP"
Writes messages to syslog instead of stderr; severity as defined with -d
option\&. With optional , the syslog type can
be selected, default is "daemon"\&.
.IP "\fB\f(CW-lf\fP\fP\f(CW \fP"
Writes messages to [filename] instead of
stderr\&.
.IP "\fB\f(CW-ls\fP\fP"
Writes messages to stderr (this is the default)\&.
.IP "\fB\f(CW-lp\fP\fP\f(CW\fP"
Overrides the program name printed in error messages\&.
.IP "\fB\f(CW-lu\fP\fP"
Extends the timestamp of error messages to microsecond resolution\&. Does not
work when logging to syslog\&.
.IP "\fB\f(CW-lm[]\fP\fP"
Mixed log mode\&. During startup messages are printed to stderr; when \fBsocat\fP
starts the transfer phase loop or daemon mode (i\&.e\&. after opening all
streams and before starting data transfer, or, with listening sockets with
fork option, before the first accept call), it switches logging to syslog\&.
With optional , the syslog type can be
selected, default is "daemon"\&.
.IP "\fB\f(CW-v\fP\fP"
Writes the transferred data not only to their target streams, but also to
stderr\&. The output format is text with some conversions for readability, and
prefixed with "> " or "< " indicating flow directions\&.
.IP "\fB\f(CW-x\fP\fP"
Writes the transferred data not only to their target streams, but also to
stderr\&. The output format is hexadecimal, prefixed with "> " or "< "
indicating flow directions\&. Can be combined with \f(CW-v\fP\&.
.IP "\fB\f(CW-b\fP\fP\f(CW\fP"
Sets the data transfer block [size_t]\&.
At most bytes are transferred per step\&. Default is 8192 bytes\&.
.IP "\fB\f(CW-s\fP\fP"
By default, \fBsocat\fP terminates when an error occurred to prevent the process
from running when some option could not be applied\&. With this
option, \fBsocat\fP is sloppy with errors and tries to continue\&. Even with this
option, socat will exit on fatals, and will abort connection attempts when
security checks failed\&.
.IP "\fB\f(CW-t\fP\fP\f(CW\fP"
When one channel has reached EOF, the write part of the other channel is shut
down\&. Then, \fBsocat\fP waits [timeval] seconds
before terminating\&. Default is 0\&.5 seconds\&.
.IP "\fB\f(CW-u\fP\fP"
Uses unidirectional mode\&. The first address is only used for reading, and the
second address is only used for writing\&.
.IP "\fB\f(CW-U\fP\fP"
Uses unidirectional mode in reverse direction\&. The first address is only
used for writing, and the second address is only used for reading\&.
.IP "\fB\f(CW-g\fP\fP"
During address option parsing, don\'t check if the option is considered
useful in the given address environment\&. Use it if you want to force, e\&.g\&.,
appliance of a socket option to a serial device\&.
.IP "\fB\f(CW-L\fP\fP\f(CW\fP"
If lockfile exists, exits with error\&. If lockfile does not exist, creates it
and continues, unlinks lockfile on exit\&.
.IP "\fB\f(CW-W\fP\fP\f(CW\fP"
If lockfile exists, waits until it disappears\&. When lockfile does not exist,
creates it and continues, unlinks lockfile on exit\&.
.PP
.SH "ADDRESS SPECIFICATIONS"
.PP
With the address command line arguments, the user gives \fBsocat\fP instructions and
the necessary information for establishing the byte streams\&.
.PP
An address specification usually consists of an address type
keyword, zero or more required address parameters separated by \':\' from the keyword and
from each
other, and zero or more address options separated by \',\'\&.
.PP
The keyword specifies the address type (e\&.g\&., TCP4, OPEN, EXEC)\&. For some
keywords there exist synonyms (\'-\' for STDIO, TCP for TCP4)\&. Keywords are case
insensitive\&.
For a few special address types, the keyword may be omitted:
Address specifications starting with a number are assumed to be FD (raw file
descriptor) addresses;
if a \'/\' is found before the first \':\' or \',\', GOPEN (generic file open) is
assumed\&.
.PP
The required number and type of address parameters depend on the address
type\&. E\&.g\&., TCP4 requires a server specification (name or address), and a port
specification (number or service name)\&.
.PP
Zero or more address options may be given with each address\&. They influence the
address in some ways\&.
Options consist of an option keyword or an option keyword and a value,
separated by \'=\'\&. Option keywords are case insensitive\&.
For filtering the options that are useful with an address
type, each option is member of one option group\&. For
each address type there is a set of option groups allowed\&. Only options
belonging to one of these address groups may be used (except with option -g)\&.
.PP
Address specifications following the above schema are also called \fIsingle\fP
address specifications\&.
Two single addresses can be combined with "!!" to form a \fIdual\fP type
address for one channel\&. Here, the first address is used by \fBsocat\fP for reading
data, and the
second address for writing data\&. There is no way to specify an option only once
for being applied to both single addresses\&.
.PP
Usually, addresses are opened in read/write
mode\&. When an address is part of a dual address specification, or when
option -u or -U is used, an address might be
used only for reading or for writing\&. Considering this is important with some
address types\&.
.PP
.SH "ADDRESS TYPES"
.PP
This section describes the available address types with their keywords,
parameters, and semantics\&.
.PP
.IP "\fB\f(CWCREATE:\fP\fP"
Opens with \f(CWcreat()\fP and uses the file
descriptor for writing\&.
This address type requires write-only context, because a file opened with
\f(CWcreat\fP cannot be read from\&.
must be a valid existing or not existing path\&.
If is a named pipe, \f(CWcreat()\fP might block;
if refers to a socket, this is an error\&.
.br
Option groups: FD,REG,NAMED
.br
Useful options:
mode,
user,
group,
unlink-early,
unlink-late,
append
.br
See also: OPEN, GOPEN
.IP "\fB\f(CWEXEC:\fP\fP"
Forks a sub process that establishes communication with its parent process
and invokes the specified program with \f(CWexecvp()\fP\&.
is a simple command
with arguments separated by single spaces\&. If the program name
contains a \'/\', the part after the last \'/\' is taken as ARGV[0]\&. If the
program name is a relative
path, the \f(CWexecvp()\fP semantics for finding the program via
\f(CW$PATH\fP
apply\&. After successful program start, \fBsocat\fP writes data to stdin of the
process and reads from its stdout using a UNIX domain socket generated by
\f(CWsocketpair()\fP per default\&.
.br
Option groups: FD,SOCKET,EXEC,FORK,TERMIOS
.br
Useful options:
path,
fdin,
fdout,
chroot,
su,
su-d,
nofork,
pty,
stderr,
ctty,
setsid,
pipes,
login,
sigint,
sigquit
.br
See also: SYSTEM
.IP "\fB\f(CWFD:\fP\fP"
Uses the file descriptor \&. It must already exist as
valid UN*X file descriptor\&.
.br
Option groups: FD (TERMIOS,REG,SOCKET)
.br
See also:
STDIO,
STDIN,
STDOUT,
STDERR
.IP "\fB\f(CWGOPEN:\fP\fP"
(Generic open) This address type tries to handle any file system entry
except directories usefully\&. may be a
relative or absolute path\&. If it already exists, its type is checked\&.
In case of a UNIX domain socket, \fBsocat\fP connects; if connecting fails,
\fBsocat\fP assumes a datagram socket and uses \f(CWsendto()\fP calls\&.
If the entry is not a socket, \fBsocat\fP opens it applying the \f(CWO_APPEND\fP
flag\&.
If it does not exist, it is opened with flag
\f(CWO_CREAT\fP as a regular file\&.
.br
Option groups: FD,REG,SOCKET,NAMED,OPEN
.br
See also:
OPEN,
CREATE,
UNIX-CONNECT
.IP "\fB\f(CWIP4::\fP\fP"
Opens a raw IPv4 socket with , sends packets
to [IPv4 address] and receives packets from
host\&.
Protocol 255 uses the raw socket with the IP header being part of the
data\&.
.br
Option groups: FD,SOCKET,IP4
.br
Useful options:
ttl,
broadcast
.br
See also:
IP6,
UDP4,
UDP4-LISTEN
.IP "\fB\f(CWIP6::\fP\fP"
Opens a raw IPv6 socket with , sends packets
to [IPv6 address] and receives packets from
host\&.
.br
Option groups: FD,SOCKET,IP6
.br
Useful options:
ttl,
broadcast
.br
See also:
IP4,
UDP6,
UDP6-LISTEN
.IP "\fB\f(CWOPEN:\fP\fP"
Opens using the \f(CWopen()\fP system call\&.
This operation fails on UNIX domain sockets\&.
.br
Note: This address type is rarly useful in bidirectional mode\&.
.br
Option groups: FD,REG,NAMED,OPEN
.br
Useful options:
creat,
excl,
nofollow,
append,
rdonly,
wronly,
lock,
readbytes,
ignoreeof
.br
See also:
CREATE,
GOPEN,
UNIX-CONNECT
.IP "\fB\f(CWOPENSSL::\fP\fP"
Tries to establish a SSL connection to [TCP
service] on
[IPv4 address] using TCP/IPv4\&.
.br
NOTE: The server certificate is only checked for validity against
cafile or capath, but not for
match with the server\'s name or its IP address!
.br
Option groups: FD,SOCKET,SOCK_IP4,TCP,OPENSSL,RETRY
.br
Useful options:
cipher,
method,
verify,
cafile,
capath,
certificate,
bind,
connect-timeout,
sourceport,
retry
.br
See also:
OPENSSL-LISTEN,
TCP4
.IP "\fB\f(CWOPENSSL-LISTEN:\fP\fP"
Listens on tcp4 [TCP service]\&. When a
connection is accepted, this address behaves as SSL server\&.
.br
Note: You probably want to use the certificate option with this address\&.
.br
NOTE: Without verify option, the client certificate is
not checked\&. Even with verify option, the client
certificate is only checked for validity against cafile
or capath, but not for match with the client\'s name or
its IP address!
.br
Option groups: FD,SOCKET,SOCK_IP4,TCP,LISTEN,OPENSSL,CHILD,RANGE,RETRY
.br
Useful options:
cipher,
method,
verify,
cafile,
capath,
certificate,
fork,
bind,
range,
tcpwrap,
su,
reuseaddr,
retry
.br
See also:
OPENSSL,
TCP4
.IP "\fB\f(CWPIPE:\fP\fP"
If already exists, it is opened\&.
If is does not exist, a named pipe is created and opened\&. Beginning with
socat version 1\&.4\&.3, the named pipe is removed when the address is closed
(but see option unlink-close
.br
Note: When a pipe is used for both reading and writing, it works
as echo service\&.
.br
Note: When a pipe is used for both reading and writing, and socat tries
to write more bytes than the pipe can buffer (Linux 2\&.4: 2048 bytes), socat
might block\&. Consider using socat option, e\&.g\&., \f(CW-b 2048\fP
.br
Option groups: FD,NAMED,OPEN
.br
Useful options:
rdonly,
nonblock,
group,
user,
mode,
unlink-early
.br
See also: unnamed pipe
.IP "\fB\f(CWPIPE\fP\fP"
Creates an unnamed pipe and uses it for reading and writing\&. It works as an
echo, because everything written
to it appeares immediately as read data\&.
.br
Note: When socat tries to write more bytes than the pipe can queue (Linux
2\&.4: 2048 bytes), socat might block\&. Consider, e\&.g\&., using
option \f(CW-b 2048\fP
.br
Option groups: FD
.br
See also: named pipe
.IP "\fB\f(CWPROXY:::\fP\fP"
Connects to an HTTP proxy server on port 8080 using TCP/IPv4, and sends a CONNECT
request for hostname:port\&. If the proxy grants access and succeeds to
connect to the target, data transfer between socat and the target can
start\&. Note that the traffic need not be HTTP but can be an arbitrary
protocol\&.
.br
Option groups: FD,SOCKET,IP4,TCP,HTTP,RETRY
.br
Useful options:
proxyport,
ignorecr,
proxyauth,
resolve,
crnl,
bind,
connect-timeout,
mss,
sourceport,
retry
.br
See also: SOCKS, TCP4
.IP "\fB\f(CWPTY\fP\fP"
Generates a pseudo terminal (pty) and uses its master side\&. Another process
may open the pty\'s slave side using it like a serial line or terminal\&. If
both the ptmx and the openpty mechanisms are available, ptmx is used
(POSIX)\&.
.br
Option groups: FD,NAMED,PTY,TERMIOS
.br
Useful options:
link,
openpty,
wait-slave,
mode,
user,
group
.br
See also:
UNIX-LISTEN,
PIPE,
EXEC, SYSTEM
.IP "\fB\f(CWREADLINE\fP\fP"
Uses GNU readline and history on stdio to allow editing and reusing input
lines\&. This requires the GNU readline and
history libraries\&. Note that stdio should be a (pseudo) terminal device,
otherwise readline does not seem to work\&.
.br
Option groups: FD,READLINE,TERMIOS
.br
Useful options:
history,
noecho
.br
See also:
STDIO
.IP "\fB\f(CWSOCKS4:::\fP\fP"
Connects via [IPv4 address]
to [IPv4 address]
on [TCP service],
using socks version 4 protocol\&.
.br
Option groups: FD,SOCKET,IP4,TCP,SOCKS4,RETRY
.br
Useful options:
socksuser,
socksport,
sourceport,
retry
.br
See also:
SOCKS4A,
TCP4
.IP "\fB\f(CWSOCKS4A:::\fP\fP"
Connects via [IPv4 address]
to [IPv4 address]
on [TCP service]\&.
This address uses version 4a of the socks protocol in case it cannot resolve
the hostname, thus it sends the destination host name unresolved in the
socks request\&.
.br
Option groups: FD,SOCKET,IP4,TCP,SOCKS4,RETRY
.br
Useful options:
socksuser,
socksport,
sourceport,
retry
.br
See also:
SOCKS4,
TCP4
.IP "\fB\f(CWSTDERR\fP\fP"
Uses file descriptor 2\&.
.br
Option groups: FD (TERMIOS,REG,SOCKET)
.br
See also: FD
.IP "\fB\f(CWSTDIN\fP\fP"
Uses file descriptor 0\&.
.br
Option groups: FD (TERMIOS,REG,SOCKET)
.br
Useful options:
readbytes
.br
See also: FD
.IP "\fB\f(CWSTDIO\fP\fP"
Uses file descriptor 0 for reading, and 1 for writing\&.
.br
Option groups: FD (TERMIOS,REG,SOCKET)
.br
Useful options:
readbytes
.br
See also: FD
.IP "\fB\f(CWSTDOUT\fP\fP"
Uses file descriptor 1\&.
.br
Option groups: FD (TERMIOS,REG,SOCKET)
.br
See also: FD
.IP "\fB\f(CWSYSTEM:\fP\fP"
Forks a sub process that establishes communication with its parent process
and invokes the specified program with \f(CWsystem()\fP\&. Please note that
[string] must
not contain \',\' or "!!", and that shell meta characters may have to be
protected\&.
After successful program start, \fBsocat\fP writes data to stdin of the
process and reads from its stdout\&.
.br
Option groups: FD,SOCKET,EXEC,FORK,TERMIOS
.br
Useful options:
path,
fdin,
fdout,
chroot,
su,
su-d,
nofork,
pty,
stderr,
ctty,
setsid,
pipes,
sigint,
sigquit
.br
See also: EXEC
.IP "\fB\f(CWTCP4::\fP\fP"
Connects to [TCP service] on
[IPv4 address] using TCP/IPv4\&.
.br
Option groups: FD,SOCKET,IP4,TCP,RETRY
.br
Useful options:
crnl,
bind,
connect-timeout,
tos,
mtudiscover,
mss,
nodelay,
nonblock,
sourceport,
retry,
readbytes
.br
See also:
TCP4-LISTEN,
UDP4,
TCP6,
UNIX-CONNECT
.IP "\fB\f(CWTCP4-LISTEN:\fP\fP"
Listens on [TCP service] and accepts a
TCP/IPv4 connection\&. Note that opening
this address usually blocks until a client connects\&.
.br
Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4,TCP,RETRY
.br
Useful options:
crnl,
fork,
bind,
range,
tcpwrap,
backlog,
mss,
su,
reuseaddr,
retry
.br
See also:
TCP4,
UDP4-LISTEN,
TCP6-LISTEN,
UNIX-LISTEN,
OPENSSL-LISTEN
.IP "\fB\f(CWTCP6::\fP\fP"
Connects to [TCP service] on
[IPv6 address] using TCP/IPv6\&.
.br
Option groups: FD,SOCKET,IP6,TCP,RETRY
.br
Useful options:
crnl,
bind,
connect-timeout,
tos,
nodelay,
nonblock,
retry
.br
See also:
TCP6-LISTEN,
UDP6,
TCP4
.IP "\fB\f(CWTCP6-LISTEN:\fP\fP"
Listens on TCP service] and accepts a
TCP/IPv6 connection\&. Note that opening
this address usually blocks until a client connects\&.
.br
Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP6,TCP,RETRY
.br
Useful options:
crnl,
fork,
bind,
range,
backlog,
reuseaddr,
retry
.br
See also:
TCP6,
UDP6-LISTEN,
TCP4-LISTEN
.IP "\fB\f(CWUDP4::\fP\fP"
Connects to [UDP service] on
[IPv4 address] using UDP/IPv4\&.
Please note that,
due to UDP protocol properties, no real connection is established; data has
to be sent for `connecting\' to the server, and no end-of-file condition can
be transported\&.
.br
Option groups: FD,SOCKET,IP4
.br
Useful options:
ttl,
tos,
bind,
sourceport
.br
See also:
UDP4-LISTEN,
TCP4,
UDP6
.IP "\fB\f(CWUDP4-LISTEN:\fP\fP"
Waits for a UDP/IPv4 packet arriving on
[UDP service] and `connects\' back to sender\&.
Please note that,
due to UDP protocol properties, no real connection is established; data has
to arrive from the peer first, and no end-of-file condition can be
transported\&. Note that opening
this address usually blocks until a client connects\&.
.br
Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4
.br
Useful options:
fork,
bind,
range
.br
See also:
UDP4,
TCP4-LISTEN,
UDP6-LISTEN
.IP "\fB\f(CWUDP6::\fP\fP"
Connects to [UDP service] on
[IPv6 address] using UDP/IPv6\&. Please
note that, due to UDP protocol properties, no real connection is
established; data has to be sent for `connecting\' to the server, and no
end-of-file condition can be transported\&.
.br
Option groups: FD,SOCKET,IP6
.br
Useful options:
ttl,
tos
.br
bind,
sourceport,
See also:
UDP6-LISTEN,
TCP6,
UDP4
.IP "\fB\f(CWUDP6-LISTEN:\fP\fP"
Waits for a UDP/IPv6 packet arriving on
[UDP service] and `connects\' back to sender\&.
Please note that, due to UDP protocol properties, no
real connection is established; data has to arrive from the peer first, and
no end-of-file condition can be transported\&. Note that opening
this address usually blocks until a client connects\&.
.br
Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP6
.br
Useful options:
fork,
bind,
range
.br
See also:
UDP6,
TCP6-LISTEN,
UDP4-LISTEN
.IP "\fB\f(CWUNIX-CONNECT:\fP\fP"
Connects to assuming it is a UNIX domain
socket\&.
If does not exist, this is an error;
if is not a UNIX domain socket, this is an error;
if is a UNIX domain socket, but no process is listening, this is
an error\&.
.br
Option groups: FD,SOCKET,NAMED,RETRY
.br
See also:
UNIX-LISTEN,
TCP4
.IP "\fB\f(CWUNIX-LISTEN:\fP\fP"
Listens on using a UNIX domain stream
socket and accepts a connection\&.
If exists and is not a socket, this is an error\&.
If exists and is a UNIX domain socket, binding to the address
fails (use option unlink-early!)\&.
Note that opening this address usually blocks until a client connects\&.
Beginning with socat version 1\&.4\&.3, the file system entry is removed when
this address is closed (but see option unlink-close)\&.
.br
Option groups: FD,SOCKET,NAMED,LISTEN,CHILD,RETRY
.br
Useful options:
fork,
umask,
mode,
user,
group,
unlink-early
.br
See also:
UNIX-CONNECT,
TCP4-LISTEN
.PP
.SH "ADDRESS OPTIONS"
.PP
Address options can be applied to address specifications to influence the
process of opening the addresses and the
properties of the resulting data channels\&.
.PP
For technical reasons not every option can be
applied to every address type; e\&.g\&., applying a socket option to a regular file
will fail\&. To catch most useless combinations as early as in the open phase,
the concept of \fIoption groups\fP was introduced\&. Each option belongs to one
or more option groups\&. Options can be used only with address types that support
at least one of their option groups (but see option -g)\&.
.PP
Address options have data types that their values must conform to\&.
Every address option consists of just a keyword or a keyword followed by
"=value", where value must conform to the options type\&.
Some address options manipulate parameters of system calls;
e\&.g\&., option sync sets the \f(CWO_SYNC\fP flag with the \f(CWopen()\fP call\&.
Other options cause a system or library call; e\&.g\&., with option `ttl=value\'
the \f(CWsetsockopt(fd, SOL_IP, IP_TTL, value, sizeof(int))\fP call is applied\&.
Other
options set internal \fBsocat\fP variables that are used during data transfer;
e\&.g\&., `crnl\' causes explicit character conversions\&.
A few options have more complex implementations; e\&.g\&., su-d
(substuser-delayed) inquires some user and group infos, stores them, and
applies them later after a possible \f(CWchroot()\fP call\&.
.PP
If multiple options are given to an address, their sequence in the address specification has (almost) no
effect on the sequence of their execution/application\&. Instead, \fBsocat\fP has
built in an \fIoption phase\fP model that tries to bring the options in a useful
order\&. Some options exist in different forms (e\&.g\&.,
unlink, unlink-early, unlink-late) to control the time of their execution\&.
.PP
If the same option is specified more than once within one address
specification, with equal or different values, the effect depends on the kind of option\&. Options
resulting in function calls like \f(CWsetsockopt()\fP cause multiple
invocations\&. With options that set parameters for a required call like
\f(CWopen()\fP
or set internal flags, the value of the last option occurrence is effective\&.
.PP
The existence or semantics of many options are system dependent\&. \fBSocat\fP
usually does NOT try to emulate missing libc or kernel features, it just
provides an
interface to the underlying system\&. So, if an operating system lacks a feature,
the related option is simply not available on this platform\&.
.PP
The following paragraphs introduce just the more common address options\&. For
a comprehensive reference and to find information about canonical option names,
alias names, option phases, and platforms see file \fBxio\&.help\fP\&.
.br
.br
.PP
.br
.PP
\fI\fBFD option group\fP\fP
.PP
This option group contains options that are applied to a UN*X
style file descriptor, no matter how it was generated\&.
Because all current \fBsocat\fP address types are file descriptor based, these
options may be applied to any address\&.
.br
Note: Some of these options are also member of another option group, that
provides an other, non-fd based mechanism\&.
For these options, it depends on the actual address type and its option groups
which mechanism is used\&. The second, non-fd based mechanism is prioritized\&.
.IP "\fB\f(CWcloexec=\fP\fP"
Sets the \f(CWFD_CLOEXEC\fP flag with the \f(CWfcntl()\fP system call to value
\&. If set,
the file descriptor is closed on \f(CWexec()\fP family function calls\&. \fBSocat\fP
internally handles
this flag for the fds it controls, so in most cases there will be no need to
apply this option\&.
.IP "\fB\f(CWsetlk\fP\fP"
Tries to set a discretionary lock to the whole file using the \f(CWfcntl(fd,
F_SETLK, \&.\&.\&.)\fP system call\&. If the file is already locked, this call results
in an error\&.
.IP "\fB\f(CWsetlkw\fP\fP"
Tries to set a discretionary waiting lock to the whole file using the
\f(CWfcntl(fd, F_SETLKW, \&.\&.\&.)\fP system call\&. If the file is already locked,
this call blocks\&.
.IP "\fB\f(CWflock-ex\fP\fP"
Tries to set a blocking exclusive advisory lock to the file using the
\f(CWflock(fd, LOCK_EX)\fP system call\&. \fBSocat\fP hangs in this call if the file
is locked by another process\&.
.IP "\fB\f(CWflock-ex-nb\fP\fP"
Tries to set a nonblocking exclusive advisory lock to the file using the
\f(CWflock(fd, LOCK_EX)\fP system call\&. If the file is already locked,
this option results in an error\&.
.IP "\fB\f(CWflock-sh\fP\fP"
Tries to set a blocking shared advisory lock to the file using the
\f(CWflock(fd, LOCK_SH)\fP system call\&. \fBSocat\fP hangs in this call if the file
is locked by another process\&.
.IP "\fB\f(CWflock-sh-nb\fP\fP"
Tries to set a nonblocking shared advisory lock to the file using the
\f(CWflock(fd, LOCK_SH|LOCK_NB)\fP system call\&. If the file is already locked,
this option results in an error\&.
.IP "\fB\f(CWlock\fP\fP"
Sets a blocking lock on the file\&. Uses the setlk or flock mechanism
depending on availability on the particular platform\&. If both are available,
the POSIX variant (setlkw) is selected\&.
.IP "\fB\f(CWuser=\fP\fP"
Sets the (owner) of the stream\&.
If the address is member of the NAMED option group,
\fBsocat\fP uses the \f(CWchown()\fP system call after opening the
file or binding to the UNIX domain socket (race condition!)\&.
Without filesystem entry, \fBsocat\fP sets the user of the stream
using the \f(CWfchown()\fP system call\&.
These calls might require root privilege\&.
.IP "\fB\f(CWuser-late=\fP\fP"
Sets the owner of the fd to with the \f(CWfchown()\fP
system call after opening
or connecting the channel\&.
This is useful only on file system entries\&.
.IP "\fB\f(CWgroup=\fP\fP"
Sets the of the stream\&.
If the address is member of the NAMED option group,
\fBsocat\fP uses the \f(CWchown()\fP system call after opening the
file or binding to the UNIX domain socket (race condition!)\&.
Without filesystem entry, \fBsocat\fP sets the group of the stream
with the \f(CWfchown()\fP system call\&.
These calls might require group membership or root privilege\&.
.IP "\fB\f(CWgroup-late=\fP\fP"
Sets the group of the fd to with the
\f(CWfchown()\fP system call after opening
or connecting the channel\&.
This is useful only on file system entries\&.
.IP "\fB\f(CWmode=\fP\fP"
Sets the [mode_t] (permissions) of the stream\&.
If the address is member of the NAMED option group and
uses the \f(CWopen()\fP or \f(CWcreat()\fP call, the mode is applied with these\&.
If the address is member of the NAMED option group without using these
system calls, \fBsocat\fP uses the \f(CWchmod()\fP system call after opening the
filesystem entry or binding to the UNIX domain socket (race condition!)\&.
Otherwise, \fBsocat\fP sets the mode of the stream
using \f(CWfchmod()\fP\&.
These calls might require ownership or root privilege\&.
.IP "\fB\f(CWperm-late=\fP\fP"
Sets the permissions of the fd to value
[mode_t] using the \f(CWfchmod()\fP system call after
opening or connecting the channel\&.
This is useful only on file system entries\&.
.IP "\fB\f(CWappend=\fP\fP"
Always writes data to the actual end of file\&.
If the address is member of the OPEN option group,
\fBsocat\fP uses the \f(CWO_APPEND\fP flag with the \f(CWopen()\fP system call\&.
Otherwise, \fBsocat\fP applies the \f(CWfcntl(fd, F_SETFL, O_APPEND)\fP call\&.
.IP "\fB\f(CWnonblock=\fP\fP"
Tries to open or use file in nonblocking mode\&. Its only effects are that the
\f(CWconnect()\fP call of TCP addresses does not block, and that opening a
named pipe for reading does not block\&.
If the address is member of the OPEN option group,
\fBsocat\fP uses the \f(CWO_NONBLOCK\fP flag with the \f(CWopen()\fP system call\&.
Otherwise, \fBsocat\fP applies the \f(CWfcntl(fd, F_SETFL, O_NONBLOCK)\fP call\&.
.IP "\fB\f(CWbinary\fP\fP"
Opens the file in binary mode to avoid implicit line terminator
conversions (Cygwin)\&.
.IP "\fB\f(CWtext\fP\fP"
Opens the file in text mode to force implicit line terminator conversions
(Cygwin)\&.
.IP "\fB\f(CWnoinherit\fP\fP"
Does not keep this file open in a spawned process (Cygwin)\&.
.PP
.br
.PP
\fI\fBNAMED option group\fP\fP
.PP
These options work on file system entries\&.
.br
See also options user, group, and
mode\&.
.PP
.IP "\fB\f(CWuser-early=\fP\fP"
Changes the (owner) of the file system entry before
accessing it, using the
\f(CWchown()\fP system call\&. This call might require root privilege\&.
.IP "\fB\f(CWgroup-early=\fP\fP"
Changes the of the file system entry before
accessing it, using the
\f(CWchown()\fP system call\&. This call might require group membership or root
privilege\&.
.IP "\fB\f(CWperm-early=\fP\fP"
Changes the [mode_t] of the file system entry
before accessing it, using the
\f(CWchmod()\fP system call\&. This call might require ownership or root
privilege\&.
.IP "\fB\f(CWumask=\fP\fP"
Sets the umask of the process to [mode_t] before
accessing the file system entry (useful
with UNIX domain sockets!)\&. This call might affect all further operations
of the \fBsocat\fP process!
.IP "\fB\f(CWunlink-early\fP\fP"
Unlinks (removes) the file before opening it and even before applying
user-early etc\&.
.IP "\fB\f(CWunlink\fP\fP"
Unlinks (removes) the file before accessing it, but after user-early etc\&.
.IP "\fB\f(CWunlink-late\fP\fP"
Unlinks (removes) the file after opening it to make it inaccessible for
other processes after a short race condition\&.
(
.IP "\fB\f(CWunlink-close\fP\fP"
Removes the addresses file system entry when closing the address\&.
For named pipes,
listening unix domain sockets,
and the symbolic links of pty addresses,
the default is 1; for created files,
opened files,
generic opened files, and
client unix domain sockets the default is 0\&.
.PP
.br
.PP
\fI\fBOPEN option group\fP\fP
.PP
The OPEN group options allow to set flags with the \f(CWopen()\fP system call\&.
E\&.g\&., option `creat\' sets the \f(CWO_CREAT\fP flag\&.
.br
See also options append and
nonblock\&.
.IP "\fB\f(CWcreat=\fP\fP"
Creates the file if it does not exist\&.
.IP "\fB\f(CWdsync=\fP\fP"
Blocks \f(CWwrite()\fP calls until metainfo is physically written to media\&.
.IP "\fB\f(CWexcl=\fP\fP"
With option creat, if file exists this is an error\&.
.IP "\fB\f(CWlargefile=\fP\fP"
On 32 bit systems, allows a file larger than 2^31 bytes\&.
.IP "\fB\f(CWnoctty=\fP\fP"
Does not make this file the controlling terminal\&.
.IP "\fB\f(CWnofollow=\fP\fP"
Does not follow symbolic links\&.
.IP "\fB\f(CWnshare=\fP\fP"
Does not allow to share this file with other processes\&.
.IP "\fB\f(CWrshare=\fP\fP"
Does not allow other processes to open this file for writing\&.
.IP "\fB\f(CWrsync=\fP\fP"
Blocks \f(CWwrite()\fP until metainfo is physically written to media\&.
.IP "\fB\f(CWsync=\fP\fP"
Blocks \f(CWwrite()\fP until data is physically written to media\&.
.IP "\fB\f(CWrdonly=\fP\fP"
Opens the file for reading only\&.
.IP "\fB\f(CWwronly=\fP\fP"
Opens the file for writing only\&.
.IP "\fB\f(CWtrunc\fP\fP"
Truncates the file to size 0 during opening it\&.
.PP
.br
.PP
\fI\fBREG and BLK option group\fP\fP
.PP
These options are usually applied to a UN*X file descriptor, but their
semantics make sense only on a file supporting random access\&.
.IP "\fB\f(CWseek=\fP\fP"
Applies the \f(CWlseek(fd, , SEEK_SET)\fP (or \f(CWlseek64\fP) system
call, thus positioning the file pointer absolutely to
[off_t or off64_t]\&.
.IP "\fB\f(CWseek-cur=\fP\fP"
Applies the \f(CWlseek(fd, , SEEK_CUR)\fP (or \f(CWlseek64\fP) system
call, thus positioning the file pointer [off_t or
off64_t] bytes relatively to its current position (which
is usually 0)\&.
.IP "\fB\f(CWseek-end=\fP\fP"
Applies the \f(CWlseek(fd, , SEEK_END)\fP (or \f(CWlseek64\fP) system
call, thus positioning the file pointer [off_t or
off64_t] bytes relatively to the files current end\&.
.IP "\fB\f(CWftruncate=\fP\fP"
Applies the \f(CWftruncate(fd, )\fP
(or \f(CWftruncate64\fP if available) system call, thus
truncating the file at the position [off_t or
off64_t]\&.
.PP
.br
.PP
\fI\fBPROCESS option group\fP\fP
.PP
Options of this group change the process properties instead of just affecting
one data channel\&.
For EXEC and SYSTEM addresses and for LISTEN and CONNECT type addresses with
option FORK,
these options apply to the child processes instead of the main socat process\&.
.IP "\fB\f(CWchroot=\fP\fP"
Performs a \f(CWchroot()\fP operation to
after processing the address\&. This call might require root privilege\&.
.IP "\fB\f(CWchroot-early=\fP\fP"
Performs a \f(CWchroot()\fP operation to
before opening the address\&. This call might require root privilege\&.
.IP "\fB\f(CWsetgid=\fP\fP"
Changes the primary of the process after
processing the address\&. This call might require root privilege\&.
.IP "\fB\f(CWsetgid-early=\fP\fP"
Changes the primary of the process before opening
the address\&. This call might require root privilege\&.
.IP "\fB\f(CWsetuid=\fP\fP"
Changes the (owner) of the process after processing
the address\&. This call might require root privilege\&.
.IP "\fB\f(CWsetuid-early=\fP\fP"
Changes the (owner) of the process before opening
the address\&. This call might require root privilege\&.
.IP "\fB\f(CWsu=\fP\fP"
Changes the (owner) and groups of the process after
processing the address\&. This call might require root privilege\&.
.IP "\fB\f(CWsu-d=\fP\fP"
Short name for \fB\f(CWsubstuser-delayed\fP\fP\&.
Changes the
(owner) and groups of the process after processing the address\&.
The user and his groups are retrieved \fIbefore\fP a possible
\f(CWchroot()\fP\&. This call might require root privilege\&.
.IP "\fB\f(CWsetpgid=\fP\fP"
Makes the process a member of the specified process group
\&. If no value
is given, or if the value is 0 or 1, the process becomes leader of a new
process group\&.
.IP "\fB\f(CWsetsid\fP\fP"
Makes the process the leader of a new session\&.
.PP
.br
.PP
\fI\fBREADLINE option group\fP\fP
.PP
These options apply to the readline address type\&.
.IP "\fB\f(CWhistory=\fP\fP"
Reads and writes history from/to \&.
.IP "\fB\f(CWnoprompt\fP\fP"
Since version 1\&.4\&.0, socat per default tries to determine a prompt -
that is then passed to the readline call - by remembering the last
incomplete line of the output\&. With this option, socat does not pass a
prompt to readline, so it begins line editing in the first column
of the terminal\&.
.IP "\fB\f(CWnoecho=\fP\fP"
Specifies a regular pattern for a prompt that prevents the following input
line from being displayed on the screen and from being added to the history\&.
The prompt is defined as the text that was output to the readline address
after the lastest newline character and before an input character was
typed\&. The pattern is a regular expression, e\&.g\&.
"^[Pp]assword:\&.*$" or "([Uu]ser:|[Pp]assword:)"\&. See regex(7) for details\&.
.IP "\fB\f(CWprompt=\fP\fP"
Passes the string as prompt to the readline function\&. readline prints this
prompt when stepping through the history\&. If this string matches a constant
prompt issued by an interactive program on the other socat address,
consistent look and feel can be archieved\&.
.PP
.br
.PP
\fI\fBAPPLICATION option group\fP\fP
.PP
This group contains options that work at data level\&.
Note that these options only apply to the "raw" data transferred by socat,
but not to protocol data used by addresses like
PROXY\&.
.IP "\fB\f(CWcr\fP\fP"
Converts the default line termination character NL (\'\en\', 0x0a) to/from CR
(\'\er\', 0x0d) when writing/reading on this channel\&.
.IP "\fB\f(CWcrnl\fP\fP"
Converts the default line termination character NL (\'\en\', 0x0a) to/from CRNL
("\er\en", 0x0d0a) when writing/reading on this channel\&.
Note: socat simply strips all CR characters\&.
.IP "\fB\f(CWignoreeof\fP\fP"
When EOF occurs on this channel, \fBsocat\fP ignores it and tries to read more
data (like "tail -f")\&.
.IP "\fB\f(CWreadbytes=\fP\fP"
\fBsocat\fP reads only so many bytes from this address (the address provides
only so many bytes for transfer and pretends to be at EOF afterwards)\&.
.IP "\fB\f(CWlockfile=\fP\fP"
If lockfile exists, exits with error\&. If lockfile does not exist, creates it
and continues, unlinks lockfile on exit\&.
.IP "\fB\f(CWwaitlock=\fP\fP"
If lockfile exists, waits until it disappears\&. When lockfile does not exist,
creates it and continues, unlinks lockfile on exit\&.
.PP
.br
.PP
\fI\fBSOCKET option group\fP\fP
.PP
These options are intended for all kinds of sockets, e\&.g\&. IP or UNIX domain\&. Most are applied with a \f(CWsetsockopt()\fP call\&.
.IP "\fB\f(CWbind=\fP\fP"
Binds the socket to the given socket address using the \f(CWbind()\fP system
call\&. The form of is socket domain dependent:
IP4 and IP6 allow the form [hostname|hostaddress][:(service|port)],
UNIX domain sockets require \&.
.IP "\fB\f(CWconnect-timeout=\fP\fP"
Abort the connection attempt after [timeval]
with error status\&.
.IP "\fB\f(CWinterface=\fP\fP"
Binds the socket to the given \&.
This option might require root privilege\&.
.IP "\fB\f(CWbroadcast\fP\fP"
For datagram sockets, allows sending to broadcast addresses and receiving
packets addressed to broadcast addresses\&.
.IP "\fB\f(CWbsdcompat\fP\fP"
Emulates some (old?) bugs of the BSD socket implementation\&.
.IP "\fB\f(CWdebug\fP\fP"
Enables socket debugging\&.
.IP "\fB\f(CWdontroute\fP\fP"
Only communicates with directly connected peers, does not use routers\&.
.IP "\fB\f(CWkeepalive\fP\fP"
Enables sending keepalives on the socket\&.
.IP "\fB\f(CWlinger=\fP\fP"
Blocks \f(CWshutdown()\fP or \f(CWclose()\fP until data transfers have finished
or the given timeout [int] expired\&.
.IP "\fB\f(CWoobinline\fP\fP"
Places out-of-band data in the input data stream\&.
.IP "\fB\f(CWpriority=\fP\fP"
Sets the protocol defined [] for outgoing
packets\&.
.IP "\fB\f(CWrcvbuf=\fP\fP"
Sets the size of the receive buffer after the \f(CWsocket()\fP call to
[int]\&. With TCP
sockets, this value corresponds to the socket\'s maximal window size\&.
.IP "\fB\f(CWrcvbuf-late=\fP\fP"
Sets the size of the receive buffer when the socket is already
connected to [int]\&.
With TCP sockets, this value corresponds to the socket\'s
maximal window size\&.
.IP "\fB\f(CWrcvlowat=\fP\fP"
Specifies the minimum number of received bytes [int] until
the socket layer will pass the buffered data to \fBsocat\fP\&.
.IP "\fB\f(CWrcvtimeo=\fP\fP"
Sets the receive timeout [timeval]\&.
.IP "\fB\f(CWreuseaddr\fP\fP"
Allows other sockets to bind to an address even if parts of it (e\&.g\&. the
local port) are already in use by \fBsocat\fP\&.
.IP "\fB\f(CWsndbuf=\fP\fP"
Sets the size of the send buffer after the \f(CWsocket()\fP call to
[int]\&.
.IP "\fB\f(CWsndbuf-late=\fP\fP"
Sets the size of the send buffer when the socket is connected to
[int]\&.
.IP "\fB\f(CWsndlowat=\fP\fP"
Specifies the minimum number of bytes in the send buffer until the socket
layer will send the data to [int]\&.
.IP "\fB\f(CWsndtimeo=\fP\fP"
Sets the send timeout to seconds [timeval]\&.
.IP "\fB\f(CWtype=\fP\fP"
Sets the type of the socket, usually as argument to the \f(CWsocket()\fP or
\f(CWsocketpair()\fP call, to [int]\&.
Under Linux, 1 means stream oriented socket, 2 means datagram socket, and 3
means raw socket\&.
.PP
.br
.PP
\fI\fBIP4 and IP6 option groups\fP\fP
.PP
These options can be used with IPv4 and IPv6 based sockets\&.
.IP "\fB\f(CWtos=\fP\fP"
Sets the TOS (type of service) field of outgoing packets to
[byte] (see RFC 791)\&.
.IP "\fB\f(CWttl=\fP\fP"
Sets the TTL (time to live) field of outgoing packets to
[byte]\&.
.IP "\fB\f(CWipoptions=\fP\fP"
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 \f(CWipoptions=x8307040a000001\fP\&.
.br
IP options are defined in RFC 791\&.
.br
.IP "\fB\f(CWmtudiscover=<0|1|2>\fP\fP"
Takes 0, 1, 2 to never, want, or always use path MTU discover on this
socket\&.
.PP
.br
.PP
\fI\fBTCP option group\fP\fP
.PP
These options may be applied to TCP sockets\&. They work by invoking \f(CWsetsockopt()\fP with the appropriate parameters\&.
.IP "\fB\f(CWcork\fP\fP"
Doesn\'t send packets smaller than MSS (maximal segment size)\&.
.IP "\fB\f(CWdefer-accept\fP\fP"
While listening, accepts connections only when data from the peer arrived\&.
.IP "\fB\f(CWkeepcnt=\fP\fP"
Sets the number of keepalives before shutting down the socket to
[int]\&.
.IP "\fB\f(CWkeepidle=\fP\fP"
Sets the idle time before sending the first keepalive to
[int]\&.
.IP "\fB\f(CWkeepintvl=\fP\fP"
Sets the intervall between two keepalives to
[int]\&.
.IP "\fB\f(CWlinger2=\fP\fP"
Sets the time to keep the socket in FIN-WAIT-2 state to
[int]\&.
.IP "\fB\f(CWmss=\fP\fP"
Sets the MSS (maximum segment size) after the \f(CWsocket()\fP call to
[int]\&. This
value is then proposed to the peer with the SYN or SYN/ACK packet\&.
.IP "\fB\f(CWmss-late=\fP\fP"
Sets the MSS of the socket after connection has been established to
[int]\&.
.IP "\fB\f(CWnodelay\fP\fP"
Turns off the Nagle algorithm for measuring the RTT (round trip time)\&.
.IP "\fB\f(CWrfc1323\fP\fP"
Enables RFC1323 TCP options: TCP window scale, round-trip time measurement
(RTTM), and protect against wrapped sequence numbers (PAWS) (AIX)\&.
.IP "\fB\f(CWstdurg\fP\fP"
Enables RFC1122 compliant urgent pointer handling (AIX)\&.
.IP "\fB\f(CWsyncnt=\fP\fP"
Sets the maximal number of SYN retransmits during connect to
[int]\&.
.IP "\fB\f(CWmd5sig\fP\fP"
Enables generation of MD5 digests on the packets (FreeBSD)\&.
.IP "\fB\f(CWnoopt\fP\fP"
Disables use of TCP options (FreeBSD, MacOSX)\&.
.IP "\fB\f(CWnopush\fP\fP"
sets the TCP_NOPUSH socket option (FreeBSD, MacOSX)\&.
.IP "\fB\f(CWsack-disable\fP\fP"
Disables use the selective acknowledge feature (OpenBSD)\&.
.IP "\fB\f(CWsignature-enable\fP\fP"
Enables generation of MD5 digests on the packets (OpenBSD)\&.
.IP "\fB\f(CWabort-threshold=\fP\fP"
Sets the time to wait for an answer of the peer on an established connection
(HP-UX)\&.
.IP "\fB\f(CWconn-abort-threshold=\fP\fP"
Sets the time to wait for an answer of the server during the initial connect
(HP-UX)\&.
.IP "\fB\f(CWkeepinit\fP\fP"
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)\&.
.IP "\fB\f(CWpaws\fP\fP"
Enables the "protect against wrapped sequence numbers" feature (Tru64)\&.
.IP "\fB\f(CWsackena\fP\fP"
Enables selective acknowledge (Tru64)\&.
.IP "\fB\f(CWtsoptena\fP\fP"
Enables the time stamp option that allows RTT recalculation on existing
connections (Tru64)\&.
.PP
.br
.PP
\fI\fBUDP and TCP option groups\fP\fP
.PP
Here we find options that are related to the network port mechanism and that
thus can be used with UDP and TCP, client and server addresses\&.
.IP "\fB\f(CWsourceport=\fP\fP"
For outgoing (client) TCP and UDP connections, it sets the source
using an extra \f(CWbind()\fP call\&.
With TCP or UDP listen addresses, socat immediately shuts down the
connection if the client does not use this sourceport\&.
.IP "\fB\f(CWlowport\fP\fP"
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\&.
.PP
.br
.PP
\fI\fBSOCKS option group\fP\fP
.PP
When using SOCKS type addresses, some socks specific options can be set\&.
.IP "\fB\f(CWsocksport=\fP\fP"
Overrides the default "socks" service or port 1080 for the socks server
port with \&.
.IP "\fB\f(CWsocksuser=\fP\fP"
Sends the [string] in the username field to the
socks server\&. Default is the actual user name ($LOGNAME or $USER)\&.
.PP
.br
.PP
\fI\fBHTTP option group\fP\fP
.PP
Options that can be provided with HTTP type addresses\&. The only HTTP address
currently implemented is proxy-connect\&.
.PP
.IP "\fB\f(CWproxyport=\fP\fP"
Overrides the default HTTP proxy port 8080 with
\&.
.IP "\fB\f(CWignorecr\fP\fP"
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\&.
.IP "\fB\f(CWproxyauth=:\fP\fP"
Provide "basic" authentication to the proxy server\&. The argument to the
option is used with a "Proxy-Authorization: Base" header in base64 encoded
form\&.
.br
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\&.
.IP "\fB\f(CWresolve\fP\fP"
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\&.
.PP
.br
.PP
\fI\fBRANGE option group\fP\fP
.PP
These options check if a connecting client is granted access\&. They can be
applied to listening network sockets\&.
.IP "\fB\f(CWrange=\fP\fP"
After accepting a connection, tests if the peer is within \fIrange\fP\&. This
option is currently only implemented for IPv4 addresses\&. Address range has
the form ww\&.xx\&.yy\&.zz/bits, e\&.g\&. 10\&.0\&.0\&.0/8\&. If the client address does not
match, \fBsocat\fP issues an error aborting the program
or keeps listening (see option -s)\&.
.IP "\fB\f(CWtcpwrap[=]\fP\fP"
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, see "man 5 hosts_access" for
more information\&. (type string) is passed to the wrapper functions as daemon
process name\&. 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\&.
.PP
.br
.PP
\fI\fBLISTEN option group\fP\fP
.PP
Options specific to listening sockets\&.
.IP "\fB\f(CWbacklog=\fP\fP"
Sets the backlog value passed with the \f(CWlisten()\fP system call to
[int]\&. Default is 5\&.
.br
.PP
\fI\fBCHILD option group\fP\fP
.PP
Options for addresses with multiple connections via child processes\&.
.IP "\fB\f(CWfork\fP\fP"
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\&.
.br
SSL-CONNECT and SSL-LISTEN differ in when they actually fork off the child:
SSL-LISTEN forks \fIbefore\fP the SSL handshake, while SSL-CONNECT forks
\fIafterwards\fP\&.
RETRY and FOREVER options are not inherited by the child process\&.
.br
.PP
.br
.PP
\fI\fBEXEC option group\fP\fP
.PP
Options for addresses that invoke a program\&.
.IP "\fB\f(CWpath=\fP\fP"
Overrides the PATH environment variable for searching the program with
\&. This
\f(CW$PATH\fP value is effective in the child process too\&.
.IP "\fB\f(CWlogin\fP\fP"
Prefixes \f(CWargv[0]\fP for the \f(CWexecvp()\fP call with \'-\', thus making a
shell behave as login shell\&.
.PP
.br
.PP
\fI\fBFORK option group\fP\fP
.PP
EXEC or SYSTEM addresses invoke a program using a child process and transfer data between \fBsocat\fP and the program\&. The interprocess communication mechanism can be influenced with the following options\&. Per
default, a \f(CWsocketpair()\fP is created and assigned to stdin and stdout of
the child process, while stderr is inherited from the \fBsocat\fP process, and the
child process uses file descriptors 0 and 1 for communicating with the main
socat process\&.
.IP "\fB\f(CWnofork\fP\fP"
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:
.IP o
this option can only be applied to the second \fBsocat\fP address\&.
.IP o
it cannot be applied to a part of a LINK(dual)(ADDRESS_DUAL) address\&.
.IP o
the first socat address cannot be OPENSSL or READLINE
.IP o
socat options -b, -t, -D, -l, -v, -x become useless
.IP o
for both addresses, options ignoreeof, cr, and crnl become useless
.IP 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\&.
.IP "\fB\f(CWpipes\fP\fP"
Creates a pair of unnamed pipes for interprocess communication instead of a
socket pair\&.
.IP "\fB\f(CWopenpty\fP\fP"
Establishes communication with the sub process using a pseudo terminal
created with \f(CWopenpty()\fP instead of the default (socketpair or ptmx)\&.
.IP "\fB\f(CWptmx\fP\fP"
Establishes communication with the sub process using a pseudo terminal
created by opening \fB/dev/ptmx\fP or \fB/dev/ptc\fP instead of the default
(socketpair)\&.
.IP "\fB\f(CWpty\fP\fP"
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\&.
.IP "\fB\f(CWctty\fP\fP"
Makes the pty the controlling tty of the sub process\&.
.IP "\fB\f(CWstderr\fP\fP"
Directs stderr of the sub process to its output channel by making stderr a
\f(CWdup()\fP of stdout\&.
.IP "\fB\f(CWfdin=\fP\fP"
Assigns the sub processes input channel to its file descriptor
instead of stdin (0)\&. The program started from the subprocess has to use
this fd for reading data from \fBsocat\fP\&.
.IP "\fB\f(CWfdout=\fP\fP"
Assigns the sub processes output channel to its file descriptor
instead of stdout (1)\&. The program started from the subprocess has to use
this fd for writing data to \fBsocat\fP\&.
.IP "\fB\f(CWsighup\fP\fP, \fB\f(CWsigint\fP\fP, \fB\f(CWsigquit\fP\fP"
Has \fBsocat\fP pass an eventual signal of this type to the sub process\&.
If no address has this option, socat terminates on these signals\&.
.PP
.br
.PP
\fI\fBTERMIOS option group\fP\fP
.PP
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 \fBsocat\fP\'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\&.
.PP
.IP "\fB\f(CWb0\fP\fP"
Disconnects the terminal\&.
.IP "\fB\f(CWb19200\fP\fP"
Sets the serial line speed to 19200 baud\&. Some other rates are possible; use
something like \f(CWsocat -hh |grep \' b[1-9]\'\fP to find all speeds supported by
your implementation\&.
.br
Note: On some operating systems, these options may not be
available\&. Use ispeed or ospeed
instead\&.
.IP "\fB\f(CWecho=\fP\fP"
Enables or disables local echo\&.
.IP "\fB\f(CWicanon=\fP\fP"
Sets or clears canonical mode, enabling line buffering and some special
characters\&.
.IP "\fB\f(CWraw\fP\fP"
Sets raw mode, thus passing input and output almost unprocessed\&.
.IP "\fB\f(CWignbrk=\fP\fP"
Ignores or interpretes the BREAK character (e\&.g\&., ^C)
.IP "\fB\f(CWbrkint=\fP\fP"
.IP "\fB\f(CWbs0\fP\fP"
.IP "\fB\f(CWbs1\fP\fP"
.IP "\fB\f(CWbsdly=<0|1>\fP\fP"
.IP "\fB\f(CWclocal=\fP\fP"
.IP
\.LP
\.nf
\fBcr0
cr1
cr2
cr3\fP
\.fi
\.IP
Sets the carriage return delay to 0, 1, 2, or 3, respectively\&.
0 means no delay, the other values are terminal dependent\&.
.IP
.IP "\fB\f(CWcrdly=<0|1|2|3>\fP\fP"
.IP "\fB\f(CWcread=\fP\fP"
.IP "\fB\f(CWcrtscts=\fP\fP"
.IP
\.LP
\.nf
\fBcs5
cs6
cs7
cs8\fP
\.fi
\.IP
Sets the character size to 5, 6, 7, or 8 bits, respectively\&.
.IP
.IP "\fB\f(CWcsize=<0|1|2|3>\fP\fP"
.IP "\fB\f(CWcstopb=\fP\fP"
Sets two stop bits, rather than one\&.
.IP "\fB\f(CWdsusp=\fP\fP"
Sets the value for the VDSUSP character that suspends the current foreground
process and reactivates the shell (all except Linux)\&.
.IP "\fB\f(CWechoctl=\fP\fP"
Echos control characters in hat notation (e\&.g\&. ^A)
.IP "\fB\f(CWechoe=\fP\fP"
.IP "\fB\f(CWechok=\fP\fP"
.IP "\fB\f(CWechoke=\fP\fP"
.IP "\fB\f(CWechonl=\fP\fP"
.IP "\fB\f(CWechoprt=\fP\fP"
.IP "\fB\f(CWeof=\fP\fP"
.IP "\fB\f(CWeol=\fP\fP"
.IP "\fB\f(CWeol2=