COMMENT(source: socat.yo)
mailto(socat@dest-unreach.org)
def(unix)(0)(UN*X)
def(unixdomain)(0)(UNIX domain)
def(socat)(0)(bf(socat))
def(Socat)(0)(bf(Socat))
def(filan)(0)(bf(filan))
def(Filan)(0)(bf(Filan))
def(procan)(0)(bf(procan))
def(Procan)(0)(bf(Procan))
manpage(socat)(1)(March 2007)(socat)()
whenhtml(
label(CONTENTS)
manpagesection(CONTENTS)
link(NAME)(NAME)nl()
link(SYNOPSIS)(SYNOPSIS)nl()
link(DESCRIPTION)(DESCRIPTION)nl()
link(OPTIONS)(OPTIONS)nl()
link(ADDRESS SPECIFICATIONS)(ADDRESS_SPECIFICATIONS)nl()
link(ADDRESS TYPES)(ADDRESS_TYPES)nl()
link(ADDRESS OPTIONS)(ADDRESS_OPTIONS)nl()
link(DATA VALUES)(VALUES)nl()
link(EXAMPLES)(EXAMPLES)nl()
link(DIAGNOSTICS)(DIAGNOSTICS)nl()
link(FILES)(FILES)nl()
link(ENVIRONMENT VARIABLES)(ENVIRONMENT_VARIABLES)nl()
link(CREDITS)(CREDITS)nl()
link(VERSION)(VERSION)nl()
link(BUGS)(BUGS)nl()
link(SEE ALSO)(SEEALSO)nl()
)
label(NAME)
manpagename(socat) (Multipurpose relay (SOcket CAT))
label(SYNOPSIS)
manpagesynopsis()
tt(socat [options]
)nl()
tt(socat -V)nl()
tt(socat -h[h[h]] | -?[?[?]])nl()
tt(filan)nl()
tt(procan)
label(DESCRIPTION)
manpagedescription()
Socat() 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 link(address types)(ADDRESS_TYPES)), and because lots of
link(address options)(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'.
Filan() is a utility that prints information about its active file
descriptors to stdout. It has been written for debugging socat(), but might be
useful for other purposes too. Use the -h option to find more infos.
Procan() 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 socat(), but might be
useful for other purposes too.
The life cycle of a socat() instance typically consists of four phases.
In the em(init) phase, the command line options are parsed and logging is
initialized.
During the em(open) phase, socat() opens the first address and afterwards the
second address. These steps are usually blocking; thus, especially for complex address types like socks,
connection requests or authentication dialogs must be completed before the next
step is started.
In the em(transfer) phase, socat() watches both streams' read and write file
descriptors via code(select()), and, when data is available on one side em(and)
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.
When one of the streams effectively reaches EOF, the em(closing) phase
begins. Socat() transfers the EOF condition to the other stream,
i.e. tries to shutdown only its write stream, giving it a chance to
terminate gracefully. For a defined time socat() continues to transfer data in
the other direction, but then closes all remaining channels and terminates.
label(OPTIONS)
manpageoptions()
Socat() provides some command line options that modify the behaviour of the
program. They have nothing to do with so called
link(address options)(ADDRESS_OPTIONS) that are used as parts of link(address specifications)(ADDRESS_SPECIFICATIONS).
startdit()
dit(bf(tt(-V)))
Print version and available feature information to stdout, and exit.
dit(bf(tt(-h | -?)))
Print a help text to stdout describing command line options and available address
types, and exit.
dit(bf(tt(-hh | -??)))
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.
dit(bf(tt(-hhh | -???)))
Like -hh, plus a list of all available address option names.
label(option_d)dit(bf(tt(-d)))
Without this option, only fatal and error messages are generated; applying
this option also prints warning messages. See link(DIAGNOSTICS)(DIAGNOSTICS)
for more information.
label(option_d_d)dit(bf(tt(-d -d))) Prints fatal, error, warning, and notice messages.
dit(bf(tt(-d -d -d))) Prints fatal, error, warning, notice, and info messages.
dit(bf(tt(-d -d -d -d))) Prints fatal, error, warning, notice, info, and debug
messages.
dit(bf(tt(-D)))
Logs information about file descriptors before starting the transfer phase.
dit(bf(tt(-ly[])))
Writes messages to syslog instead of stderr; severity as defined with -d
option. With optional link()(TYPE_FACILITY), the syslog type can
be selected, default is "daemon".
dit(bf(tt(-lf))tt( ))
Writes messages to [link(filename)(TYPE_FILENAME)] instead of
stderr.
dit(bf(tt(-ls)))
Writes messages to stderr (this is the default).
label(option_lp)dit(bf(tt(-lp))tt())
Overrides the program name printed in error messages.
dit(bf(tt(-lu)))
Extends the timestamp of error messages to microsecond resolution. Does not
work when logging to syslog.
label(option_lm)dit(bf(tt(-lm[])))
Mixed log mode. During startup messages are printed to stderr; when socat()
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 link()(TYPE_FACILITY), the syslog type can be
selected, default is "daemon".
label(option_lh)dit(bf(tt(-lh)))
Adds hostname to log messages. Uses the value from environment variable
HOSTNAME or the value retrieved with tt(uname()) if HOSTNAME is not set.
dit(bf(tt(-v)))
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.
dit(bf(tt(-x)))
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 code(-v).
label(option_b)dit(bf(tt(-b))tt())
Sets the data transfer block [link(size_t)(TYPE_SIZE_T)].
At most bytes are transferred per step. Default is 8192 bytes.
label(option_s)dit(bf(tt(-s)))
By default, socat() terminates when an error occurred to prevent the process
from running when some option could not be applied. With this
option, socat() 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.
label(option_t)dit(bf(tt(-t))tt())
When one channel has reached EOF, the write part of the other channel is shut
down. Then, socat() waits [link(timeval)(TYPE_TIMEVAL)] seconds
before terminating. Default is 0.5 seconds. This timeout only applies to
addresses where write and read part can be closed independently. When during
the timeout intervall the read part gives EOF, socat terminates without
awaiting the timeout.
label(option_T)dit(bf(tt(-T))tt())
Total inactivity timeout: when socat is already in the transfer loop and
nothing has happened for [link(timeval)(TYPE_TIMEVAL)] seconds
(no data arrived, no interrupt occurred...) then it terminates.
Useful with protocols like UDP that cannot transfer EOF.
label(option_u)dit(bf(tt(-u)))
Uses unidirectional mode. The first address is only used for reading, and the
second address is only used for writing (link(example)(EXAMPLE_option_u)).
label(option_U)dit(bf(tt(-U)))
Uses unidirectional mode in reverse direction. The first address is only
used for writing, and the second address is only used for reading.
label(option_g)dit(bf(tt(-g)))
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.
label(option_L)dit(bf(tt(-L))tt())
If lockfile exists, exits with error. If lockfile does not exist, creates it
and continues, unlinks lockfile on exit.
label(option_W)dit(bf(tt(-W))tt())
If lockfile exists, waits until it disappears. When lockfile does not exist,
creates it and continues, unlinks lockfile on exit.
label(option_4)dit(bf(tt(-4)))
Use IP version 4 in case that the addresses do not implicitly or explicitly
specify a version; this is the default.
label(option_6)dit(bf(tt(-6)))
Use IP version 6 in case that the addresses do not implicitly or explicitly
specify a version.
enddit()
label(ADDRESS_SPECIFICATIONS)
manpagesection(ADDRESS SPECIFICATIONS)
With the address command line arguments, the user gives socat() instructions and
the necessary information for establishing the byte streams.
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 ','.
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.
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).
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 link(option -g)(option_g)).
label(ADDRESS_DUAL)
Address specifications following the above schema are also called em(single)
address specifications.
Two single addresses can be combined with "!!" to form a em(dual) type
address for one channel. Here, the first address is used by socat() 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.
Usually, addresses are opened in read/write
mode. When an address is part of a dual address specification, or when
link(option -u)(option_u) or link(-U)(option_U) is used, an address might be
used only for reading or for writing. Considering this is important with some
address types.
With socat version 1.5.0 and higher, the lexical analysis tries to handle
quotes and parenthesis meaningfully and allows escaping of special characters.
If one of the characters ( { [ ' is found, the corresponding closing
character - ) } ] ' - is looked for; they may also be nested. Within these
constructs, socats special characters and strings : , !! are not handled
specially. All those characters and strings can be escaped with \ or within ""
label(ADDRESS_TYPES)
manpagesection(ADDRESS TYPES)
This section describes the available address types with their keywords,
parameters, and semantics.
startdit()
label(ADDRESS_CREAT)dit(bf(tt(CREATE:)))
Opens link()(TYPE_FILENAME) with code(creat()) and uses the file
descriptor for writing.
This address type requires write-only context, because a file opened with
code(creat) cannot be read from.
must be a valid existing or not existing path.
If is a named pipe, code(creat()) might block;
if refers to a socket, this is an error.nl()
Option groups: link(FD)(GROUP_FD),link(REG)(GROUP_REG),link(NAMED)(GROUP_NAMED) nl()
Useful options:
link(mode)(OPTION_MODE),
link(user)(OPTION_USER),
link(group)(OPTION_GROUP),
link(unlink-early)(OPTION_UNLINK_EARLY),
link(unlink-late)(OPTION_UNLINK_LATE),
link(append)(OPTION_APPEND)nl()
See also: link(OPEN)(ADDRESS_OPEN), link(GOPEN)(ADDRESS_GOPEN)
label(ADDRESS_EXEC)dit(bf(tt(EXEC:)))
Forks a sub process that establishes communication with its parent process
and invokes the specified program with code(execvp()).
link()(TYPE_COMMAND_LINE) 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 code(execvp()) semantics for finding the program via
code($PATH)
apply. After successful program start, socat() writes data to stdin of the
process and reads from its stdout using a unixdomain() socket generated by
code(socketpair()) per default. (link(example)(EXAMPLE_ADDRESS_EXEC)) nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(EXEC)(GROUP_EXEC),link(FORK)(GROUP_FORK),link(TERMIOS)(GROUP_TERMIOS) nl()
Useful options:
link(path)(OPTION_PATH),
link(fdin)(OPTION_FDIN),
link(fdout)(OPTION_FDOUT),
link(chroot)(OPTION_CHROOT),
link(su)(OPTION_SUBSTUSER),
link(su-d)(OPTION_SUBSTUSER_DELAYED),
link(nofork)(OPTION_NOFORK),
link(pty)(OPTION_PTY),
link(stderr)(OPTION_STDERR),
link(ctty)(OPTION_CTTY),
link(setsid)(OPTION_SETSID),
link(pipes)(OPTION_PIPES),
link(login)(OPTION_LOGIN),
link(sigint)(OPTION_SIGINT),
link(sigquit)(OPTION_SIGQUIT)nl()
See also: link(SYSTEM)(ADDRESS_SYSTEM)
label(ADDRESS_FD)dit(bf(tt(FD:)))
Uses the file descriptor link()(TYPE_FDNUM). It must already exist as
valid unix() file descriptor.nl()
Option groups: link(FD)(GROUP_FD) (link(TERMIOS)(GROUP_TERMIOS),link(REG)(GROUP_REG),link(SOCKET)(GROUP_SOCKET)) nl()
See also:
link(STDIO)(ADDRESS_STDIO),
link(STDIN)(ADDRESS_STDIN),
link(STDOUT)(ADDRESS_STDOUT),
link(STDERR)(ADDRESS_STDERR)
label(ADDRESS_GOPEN)dit(bf(tt(GOPEN:)))
(Generic open) This address type tries to handle any file system entry
except directories usefully. link()(TYPE_FILENAME) may be a
relative or absolute path. If it already exists, its type is checked.
In case of a unixdomain() socket, socat() connects; if connecting fails,
socat() assumes a datagram socket and uses code(sendto()) calls.
If the entry is not a socket, socat() opens it applying the code(O_APPEND)
flag.
If it does not exist, it is opened with flag
code(O_CREAT) as a regular file (link(example)(EXAMPLE_ADDRESS_GOPEN)).nl()
Option groups: link(FD)(GROUP_FD),link(REG)(GROUP_REG),link(SOCKET)(GROUP_SOCKET),link(NAMED)(GROUP_NAMED),link(OPEN)(GROUP_OPEN) nl()
See also:
link(OPEN)(ADDRESS_OPEN),
link(CREATE)(ADDRESS_CREAT),
link(UNIX-CONNECT)(ADDRESS_UNIX_CONNECT)
label(ADDRESS_IP_SENDTO)dit(bf(tt(IP-SENDTO::)))
Opens a raw IP socket. Depending on host specification or option link(pf)(OPTION_PROTOCOL_FAMILY), IP procotol version
4 or 6 is used. It uses link()(TYPE_PROTOCOL) to send packets
to [link(IP address)(TYPE_IP_ADDRESS)] and receives packets from
host, ignores packets from other hosts.
Protocol 255 uses the raw socket with the IP header being part of the
data.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6) nl()
Useful options:
link(pf)(OPTION_PROTOCOL_FAMILY),
link(ttl)(OPTION_TTL)
See also:
link(IP4-SENDTO)(ADDRESS_IP4_SENDTO),
link(IP6-SENDTO)(ADDRESS_IP6_SENDTO),
link(IP-RECVFROM)(ADDRESS_IP_RECVFROM),
link(IP-RECV)(ADDRESS_IP_RECV),
link(UDP-SENDTO)(ADDRESS_UDP_SENDTO)
link(UNIX-SENDTO)(ADDRESS_UNIX_SENDTO)
label(ADDRESS_IP4_SENDTO)dit(bf(tt(IP4-SENDTO::)))
Like link(IP-SENDTO)(ADDRESS_IP_SENDTO), but always uses IPv4.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4) nl()
label(ADDRESS_IP6_SENDTO)dit(bf(tt(IP6-SENDTO::)))
Like link(IP-SENDTO)(ADDRESS_IP_SENDTO), but always uses IPv6.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP6)(GROUP_IP6) nl()
label(ADDRESS_IP_DATAGRAM)dit(bf(tt(IP-DATAGRAM::)))
Sends outgoing data to the specified address which may in particular be a
broadcast or multicast address. Packets arriving on the local socket are
checked if their source addresses match
eventual link(RANGE)(OPTION_RANGE) or link(TCPWRAP)(OPTION_TCPWRAPPERS)
options. This address type can for example be used for implementing
symmetric or asymmetric broadcast or multicast communications.nl()
Option groups: link(FD)(GROUP_FD), link(SOCKET)(GROUP_SOCKET),
link(IP4)(GROUP_IP4), link(IP6)(GROUP_IP6), link(RANGE)(GROUP_RANGE) nl()
Useful options:
link(range)(OPTION_RANGE),
link(tcpwrap)(OPTION_TCPWRAPPERS),
link(broadcast)(OPTION_SO_BROADCAST),
link(ip-multicast-loop)(OPTION_IP_MULTICAST_LOOP),
link(ip-multicast-ttl)(OPTION_IP_MULTICAST_TTL),
link(ip-multicast-if)(OPTION_IP_MULTICAST_IF),
link(ip-add-membership)(OPTION_IP_ADD_MEMBERSHIP),
link(ttl)(OPTION_TTL),
link(tos)(OPTION_TOS),
link(bind)(OPTION_BIND),
link(pf)(OPTION_PROTOCOL_FAMILY)nl()
See also:
link(IP4-DATAGRAM)(ADDRESS_IP4_DATAGRAM),
link(IP6-DATAGRAM)(ADDRESS_IP6_DATAGRAM),
link(IP-SENDTO)(ADDRESS_IP_SENDTO),
link(IP-RECVFROM)(ADDRESS_IP_RECVFROM),
link(IP-RECV)(ADDRESS_IP_RECV),
link(UDP-DATAGRAM)(ADDRESS_UDP_DATAGRAM)
label(ADDRESS_IP4_DATAGRAM)dit(bf(tt(IP4-DATAGRAM::)))
Like link(IP-DATAGRAM)(ADDRESS_IP_DATAGRAM), but always uses IPv4.
(link(example)(EXAMPLE_ADDRESS_IP4_BROADCAST_CLIENT))nl()
Option groups: link(FD)(GROUP_FD), link(SOCKET)(GROUP_SOCKET),
link(IP4)(GROUP_IP4), link(RANGE)(GROUP_RANGE) nl()
label(ADDRESS_IP6_DATAGRAM)dit(bf(tt(IP6-DATAGRAM::)))
Like link(IP-DATAGRAM)(ADDRESS_IP_DATAGRAM), but always uses IPv6. Please
note that IPv6 does not know broadcasts.nl()
Option groups: link(FD)(GROUP_FD), link(SOCKET)(GROUP_SOCKET),
link(IP6)(GROUP_IP6), link(RANGE)(GROUP_RANGE) nl()
label(ADDRESS_IP_RECVFROM)dit(bf(tt(IP-RECVFROM:)))
Opens a raw IP socket of link()(TYPE_PROTOCOL). Depending on option link(pf)(OPTION_PROTOCOL_FAMILY), IP procotol version
4 or 6 is used. It receives one packet from an unspecified peer and may send one or more answer packets to that peer.
This mode is particularly useful with fork option where each arriving packet - from arbitrary peers - is handled by its own sub process.
This allows a behaviour similar to typical UDP based servers like ntpd or named.
This address works well with IP-SENDTO address peers (see above).
Protocol 255 uses the raw socket with the IP header being part of the
data.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6),link(CHILD)(GROUP_CHILD),link(RANGE)(GROUP_RANGE) nl()
Useful options:
link(pf)(OPTION_PROTOCOL_FAMILY),
link(fork)(OPTION_FORK),
link(range)(OPTION_RANGE),
link(ttl)(OPTION_TTL),
link(broadcast)(OPTION_SO_BROADCAST)nl()
See also:
link(IP4-RECVFROM)(ADDRESS_IP4_RECVFROM),
link(IP6-RECVFROM)(ADDRESS_IP6_RECVFROM),
link(IP-SENDTO)(ADDRESS_IP_SENDTO),
link(IP-RECV)(ADDRESS_IP_RECV),
link(UDP-RECVFROM)(ADDRESS_UDP_RECVFROM),
link(UNIX-RECVFROM)(ADDRESS_UNIX_RECVFROM)
label(ADDRESS_IP4_RECVFROM)dit(bf(tt(IP4-RECVFROM:)))
Like link(IP-RECVFROM)(ADDRESS_IP_RECVFROM), but always uses IPv4.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(CHILD)(GROUP_CHILD),link(RANGE)(GROUP_RANGE) nl()
label(ADDRESS_IP6_RECVFROM)dit(bf(tt(IP6-RECVFROM:)))
Like link(IP-RECVFROM)(ADDRESS_IP_RECVFROM), but always uses IPv6.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP6)(GROUP_IP6),link(CHILD)(GROUP_CHILD),link(RANGE)(GROUP_RANGE) nl()
label(ADDRESS_IP_RECV)dit(bf(tt(IP-RECV:)))
Opens a raw IP socket of link()(TYPE_PROTOCOL). Depending on option link(pf)(OPTION_PROTOCOL_FAMILY), IP procotol version
4 or 6 is used. It receives packets from multiple unspecified peers and merges the data.
No replies are possible.
It can be, e.g., addressed by socat IP-SENDTO address peers.
Protocol 255 uses the raw socket with the IP header being part of the
data.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6),link(RANGE)(GROUP_RANGE) nl()
Useful options:
link(pf)(OPTION_PROTOCOL_FAMILY),
link(range)(OPTION_RANGE)nl()
See also:
link(IP4-RECV)(ADDRESS_IP4_RECV),
link(IP6-RECV)(ADDRESS_IP6_RECV),
link(IP-SENDTO)(ADDRESS_IP_SENDTO),
link(IP-RECVFROM)(ADDRESS_IP_RECVFROM),
link(UDP-RECV)(ADDRESS_UDP_RECV),
link(UNIX-RECV)(ADDRESS_UNIX_RECV)
label(ADDRESS_IP4_RECV)dit(bf(tt(IP4-RECV:)))
Like link(IP-RECV)(ADDRESS_IP_RECV), but always uses IPv4.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(RANGE)(GROUP_RANGE) nl()
label(ADDRESS_IP6_RECV)dit(bf(tt(IP6-RECV:)))
Like link(IP-RECV)(ADDRESS_IP_RECV), but always uses IPv6.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP6)(GROUP_IP6),link(RANGE)(GROUP_RANGE) nl()
label(ADDRESS_OPEN)dit(bf(tt(OPEN:)))
Opens link()(TYPE_FILENAME) using the code(open()) system call
(link(example)(EXAMPLE_ADDRESS_OPEN)).
This operation fails on unixdomain() sockets. nl()
Note: This address type is rarly useful in bidirectional mode.nl()
Option groups: link(FD)(GROUP_FD),link(REG)(GROUP_REG),link(NAMED)(GROUP_NAMED),link(OPEN)(GROUP_OPEN) nl()
Useful options:
link(creat)(OPTION_CREAT),
link(excl)(OPTION_EXCL),
link(noatime)(OPTION_O_NOATIME),
link(nofollow)(OPTION_NOFOLLOW),
link(append)(OPTION_APPEND),
link(rdonly)(OPTION_RDONLY),
link(wronly)(OPTION_WRONLY),
link(lock)(OPTION_LOCK),
link(readbytes)(OPTION_READBYTES),
link(ignoreeof)(OPTION_IGNOREEOF)nl()
See also:
link(CREATE)(ADDRESS_CREAT),
link(GOPEN)(ADDRESS_GOPEN),
link(UNIX-CONNECT)(ADDRESS_UNIX_CONNECT)
label(ADDRESS_OPENSSL_CONNECT)dit(bf(tt(OPENSSL::)))
Tries to establish a SSL connection to [link(TCP
service)(TYPE_TCP_SERVICE)] on
[link(IP address)(TYPE_IP_ADDRESS)] using TCP/IP version 4 or 6
depending on address specification, name resolution, or option
link(pf)(OPTION_PROTOCOL_FAMILY).nl()
NOTE: The server certificate is only checked for validity against
link(cafile)(OPTION_OPENSSL_CAFILE) or link(capath)(OPTION_OPENSSL_CAPATH),
but not for match with the server's name or its IP address!nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6),link(TCP)(GROUP_TCP),link(OPENSSL)(GROUP_OPENSSL),link(RETRY)(GROUP_RETRY) nl()
Useful options:
link(cipher)(OPTION_OPENSSL_CIPHERLIST),
link(method)(OPTION_OPENSSL_METHOD),
link(verify)(OPTION_OPENSSL_VERIFY),
link(cafile)(OPTION_OPENSSL_CAFILE),
link(capath)(OPTION_OPENSSL_CAPATH),
link(certificate)(OPTION_OPENSSL_CERTIFICATE),
link(bind)(OPTION_BIND),
link(pf)(OPTION_PROTOCOL_FAMILY),
link(connect-timeout)(OPTION_CONNECT_TIMEOUT),
link(sourceport)(OPTION_SOURCEPORT),
link(retry)(OPTION_RETRY)nl()
See also:
link(OPENSSL-LISTEN)(ADDRESS_OPENSSL_LISTEN),
link(TCP)(ADDRESS_TCP_CONNECT)
label(ADDRESS_OPENSSL_LISTEN)dit(bf(tt(OPENSSL-LISTEN:)))
Listens on tcp [link(TCP service)(TYPE_TCP_SERVICE)].
The IP version is 4 or the one specified with
link(pf)(OPTION_PROTOCOL_FAMILY). When a
connection is accepted, this address behaves as SSL server.nl()
Note: You probably want to use the link(certificate)(OPTION_OPENSSL_CERTIFICATE) option with this address.nl()
NOTE: The client certificate is only checked for validity against
link(cafile)(OPTION_OPENSSL_CAFILE) or link(capath)(OPTION_OPENSSL_CAPATH),
but not for match with the client's name or its IP address!nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6),link(TCP)(GROUP_TCP),link(LISTEN)(GROUP_LISTEN),link(OPENSSL)(GROUP_OPENSSL),link(CHILD)(GROUP_CHILD),link(RANGE)(GROUP_RANGE),link(RETRY)(GROUP_RETRY) nl()
Useful options:
link(pf)(OPTION_PROTOCOL_FAMILY),
link(cipher)(OPTION_OPENSSL_CIPHERLIST),
link(method)(OPTION_OPENSSL_METHOD),
link(verify)(OPTION_OPENSSL_VERIFY),
link(cafile)(OPTION_OPENSSL_CAFILE),
link(capath)(OPTION_OPENSSL_CAPATH),
link(certificate)(OPTION_OPENSSL_CERTIFICATE),
link(fork)(OPTION_FORK),
link(bind)(OPTION_BIND),
link(range)(OPTION_RANGE),
link(tcpwrap)(OPTION_TCPWRAPPERS),
link(su)(OPTION_SUBSTUSER),
link(reuseaddr)(OPTION_REUSEADDR),
link(retry)(OPTION_RETRY)nl()
See also:
link(OPENSSL)(ADDRESS_OPENSSL_CONNECT),
link(TCP)(ADDRESS_TCP_CONNECT)
label(ADDRESS_NAMED_PIPE)dit(bf(tt(PIPE:)))
If link()(TYPE_FILENAME) 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 link(unlink-close)(OPTION_UNLINK_CLOSE)nl()
Note: When a pipe is used for both reading and writing, it works
as echo service.nl()
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., code(-b 2048) nl()
Option groups: link(FD)(GROUP_FD),link(NAMED)(GROUP_NAMED),link(OPEN)(GROUP_OPEN) nl()
Useful options:
link(rdonly)(OPTION_RDONLY),
link(nonblock)(OPTION_NONBLOCK),
link(group)(OPTION_GROUP),
link(user)(OPTION_USER),
link(mode)(OPTION_MODE),
link(unlink-early)(OPTION_UNLINK_EARLY)nl()
See also: link(unnamed pipe)(ADDRESS_UNNAMED_PIPE)
label(ADDRESS_UNNAMED_PIPE)dit(bf(tt(PIPE)))
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.nl()
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 code(-b 2048) nl()
Option groups: link(FD)(GROUP_FD) nl()
See also: link(named pipe)(ADDRESS_NAMED_PIPE)
label(ADDRESS_PROXY_CONNECT)dit(bf(tt(PROXY:::)))
Connects to an HTTP proxy server on port 8080 using TCP/IP version 4 or 6
depending on address specification, name resolution, or option
link(pf)(OPTION_PROTOCOL_FAMILY), 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. nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6),link(TCP)(GROUP_TCP),link(HTTP)(GROUP_HTTP),link(RETRY)(GROUP_RETRY) nl()
Useful options:
link(proxyport)(OPTION_PROXYPORT),
link(ignorecr)(OPTION_IGNORECR),
link(proxyauth)(OPTION_PROXY_AUTHORIZATION),
link(resolve)(OPTION_PROXY_RESOLVE),
link(crnl)(OPTION_CRNL),
link(bind)(OPTION_BIND),
link(connect-timeout)(OPTION_CONNECT_TIMEOUT),
link(mss)(OPTION_MSS),
link(sourceport)(OPTION_SOURCEPORT),
link(retry)(OPTION_RETRY) nl()
See also: link(SOCKS)(ADDRESS_SOCKS4), link(TCP)(ADDRESS_TCP_CONNECT)
label(ADDRESS_PTY)dit(bf(tt(PTY)))
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.
(link(example)(EXAMPLE_ADDRESS_PTY)). If
both the ptmx and the openpty mechanisms are available, ptmx is used
(POSIX).nl()
Option groups: link(FD)(GROUP_FD),link(NAMED)(GROUP_NAMED),link(PTY)(GROUP_PTY),link(TERMIOS)(GROUP_TERMIOS) nl()
Useful options:
link(link)(OPTION_SYMBOLIC_LINK),
link(openpty)(OPTION_OPENPTY),
link(wait-slave)(OPTION_PTY_WAIT_SLAVE),
link(mode)(OPTION_MODE),
link(user)(OPTION_USER),
link(group)(OPTION_GROUP)nl()
See also:
link(UNIX-LISTEN)(ADDRESS_UNIX_LISTEN),
link(PIPE)(ADDRESS_NAMED_PIPE),
link(EXEC)(ADDRESS_EXEC), link(SYSTEM)(ADDRESS_SYSTEM)
label(ADDRESS_READLINE)dit(bf(tt(READLINE)))
Uses GNU readline and history on stdio to allow editing and reusing input
lines (link(example)(EXAMPLE_ADDRESS_READLINE)). This requires the GNU readline and
history libraries. Note that stdio should be a (pseudo) terminal device,
otherwise readline does not seem to work.nl()
Option groups: link(FD)(GROUP_FD),link(READLINE)(GROUP_READLINE),link(TERMIOS)(GROUP_TERMIOS) nl()
Useful options:
link(history)(OPTION_HISTORY),
link(noecho)(OPTION_NOECHO)nl()
See also:
link(STDIO)(ADDRESS_STDIO)
label(ADDRESS_SOCKS4)dit(bf(tt(SOCKS4:::)))
Connects via [link(IP address)(TYPE_IP_ADDRESS)]
to [link(IPv4 address)(TYPE_IPV4_ADDRESS)]
on [link(TCP service)(TYPE_TCP_SERVICE)],
using socks version 4 protocol over IP version 4 or 6 depending on address specification, name resolution, or option
link(pf)(OPTION_PROTOCOL_FAMILY) (link(example)(EXAMPLE_ADDRESS_SOCKS4)).nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6),link(TCP)(GROUP_TCP),link(SOCKS4)(GROUP_SOCKS),link(RETRY)(GROUP_RETRY) nl()
Useful options:
link(socksuser)(OPTION_SOCKSUSER),
link(socksport)(OPTION_SOCKSPORT),
link(sourceport)(OPTION_SOURCEPORT),
link(pf)(OPTION_PROTOCOL_FAMILY),
link(retry)(OPTION_RETRY)nl()
See also:
link(SOCKS4A)(ADDRESS_SOCKS4A),
link(PROXY)(ADDRESS_PROXY_CONNECT),
link(TCP)(ADDRESS_TCP_CONNECT)
label(ADDRESS_SOCKS4A)dit(bf(tt(SOCKS4A:::)))
like link(SOCKS4)(ADDRESS_SOCKS4), but uses socks protocol version 4a, thus
leaving host name resolution to the socks server.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6),link(TCP)(GROUP_TCP),link(SOCKS4)(GROUP_SOCKS),link(RETRY)(GROUP_RETRY) nl()
label(ADDRESS_STDERR)dit(bf(tt(STDERR)))
Uses file descriptor 2.nl()
Option groups: link(FD)(GROUP_FD) (link(TERMIOS)(GROUP_TERMIOS),link(REG)(GROUP_REG),link(SOCKET)(GROUP_SOCKET)) nl()
See also: link(FD)(ADDRESS_FD)
label(ADDRESS_STDIN)dit(bf(tt(STDIN)))
Uses file descriptor 0.nl()
Option groups: link(FD)(GROUP_FD) (link(TERMIOS)(GROUP_TERMIOS),link(REG)(GROUP_REG),link(SOCKET)(GROUP_SOCKET)) nl()
Useful options:
link(readbytes)(OPTION_READBYTES)nl()
See also: link(FD)(ADDRESS_FD)
label(ADDRESS_STDIO)dit(bf(tt(STDIO)))
Uses file descriptor 0 for reading, and 1 for writing.nl()
Option groups: link(FD)(GROUP_FD) (link(TERMIOS)(GROUP_TERMIOS),link(REG)(GROUP_REG),link(SOCKET)(GROUP_SOCKET)) nl()
Useful options:
link(readbytes)(OPTION_READBYTES)nl()
See also: link(FD)(ADDRESS_FD)
label(ADDRESS_STDOUT)dit(bf(tt(STDOUT)))
Uses file descriptor 1.nl()
Option groups: link(FD)(GROUP_FD) (link(TERMIOS)(GROUP_TERMIOS),link(REG)(GROUP_REG),link(SOCKET)(GROUP_SOCKET)) nl()
See also: link(FD)(ADDRESS_FD)
label(ADDRESS_SYSTEM)dit(bf(tt(SYSTEM:)))
Forks a sub process that establishes communication with its parent process
and invokes the specified program with code(system()). Please note that
[link(string)(TYPE_STRING)] must
not contain ',' or "!!", and that shell meta characters may have to be
protected.
After successful program start, socat() writes data to stdin of the
process and reads from its stdout.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(EXEC)(GROUP_EXEC),link(FORK)(GROUP_FORK),link(TERMIOS)(GROUP_TERMIOS) nl()
Useful options:
link(path)(OPTION_PATH),
link(fdin)(OPTION_FDIN),
link(fdout)(OPTION_FDOUT),
link(chroot)(OPTION_CHROOT),
link(su)(OPTION_SUBSTUSER),
link(su-d)(OPTION_SUBSTUSER_DELAYED),
link(nofork)(OPTION_NOFORK),
link(pty)(OPTION_PTY),
link(stderr)(OPTION_STDERR),
link(ctty)(OPTION_CTTY),
link(setsid)(OPTION_SETSID),
link(pipes)(OPTION_PIPES),
link(sigint)(OPTION_SIGINT),
link(sigquit)(OPTION_SIGQUIT)nl()
See also: link(EXEC)(ADDRESS_EXEC)
label(ADDRESS_TCP_CONNECT)dit(bf(tt(TCP::)))
Connects to [link(TCP service)(TYPE_TCP_SERVICE)] on
[link(IP address)(TYPE_IP_ADDRESS)] using TCP/IP version 4 or 6
depending on address specification, name resolution, or option
link(pf)(OPTION_PROTOCOL_FAMILY).nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6),link(TCP)(GROUP_TCP),link(RETRY)(GROUP_RETRY) nl()
Useful options:
link(crnl)(OPTION_CRNL),
link(bind)(OPTION_BIND),
link(pf)(OPTION_PROTOCOL_FAMILY),
link(connect-timeout)(OPTION_CONNECT_TIMEOUT),
link(tos)(OPTION_TOS),
link(mtudiscover)(OPTION_MTUDISCOVER),
link(mss)(OPTION_MSS),
link(nodelay)(OPTION_NODELAY),
link(nonblock)(OPTION_NONBLOCK),
link(sourceport)(OPTION_SOURCEPORT),
link(retry)(OPTION_RETRY),
link(readbytes)(OPTION_READBYTES)nl()
See also:
link(TCP4)(ADDRESS_TCP4_CONNECT),
link(TCP6)(ADDRESS_TCP6_CONNECT),
link(TCP-LISTEN)(ADDRESS_TCP_LISTEN),
link(UDP)(ADDRESS_UDP_CONNECT),
link(UNIX-CONNECT)(ADDRESS_UNIX_CONNECT)
label(ADDRESS_TCP4_CONNECT)dit(bf(tt(TCP4::)))
Like link(TCP)(ADDRESS_TCP_CONNECT), but only supports IPv4 protocol (link(example)(EXAMPLE_ADDRESS_TCP4_CONNECT)).nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(TCP)(GROUP_TCP),link(RETRY)(GROUP_RETRY) nl()
label(ADDRESS_TCP6_CONNECT)dit(bf(tt(TCP6::)))
Like link(TCP)(ADDRESS_TCP_CONNECT), but only supports IPv6 protocol.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP6)(GROUP_IP6),link(TCP)(GROUP_TCP),link(RETRY)(GROUP_RETRY) nl()
label(ADDRESS_TCP_LISTEN)dit(bf(tt(TCP-LISTEN:)))
Listens on [link(TCP service)(TYPE_TCP_SERVICE)] and accepts a
TCP/IP connection. The IP version is 4 or the one specified with
link(pf)(OPTION_PROTOCOL_FAMILY).
Note that opening
this address usually blocks until a client connects.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(LISTEN)(GROUP_LISTEN),link(CHILD)(GROUP_CHILD),link(RANGE)(GROUP_RANGE),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6),link(TCP)(GROUP_TCP),link(RETRY)(GROUP_RETRY) nl()
Useful options:
link(crnl)(OPTION_CRNL),
link(fork)(OPTION_FORK),
link(bind)(OPTION_BIND),
link(range)(OPTION_RANGE),
link(tcpwrap)(OPTION_TCPWRAPPERS),
link(pf)(OPTION_PROTOCOL_FAMILY),
link(backlog)(OPTION_BACKLOG),
link(mss)(OPTION_MSS),
link(su)(OPTION_SUBSTUSER),
link(reuseaddr)(OPTION_REUSEADDR),
link(retry)(OPTION_RETRY),
link(retry)(OPTION_COOL_WRITE)nl()
See also:
link(TCP4-LISTEN)(ADDRESS_TCP4_CONNECT),
link(TCP6-LISTEN)(ADDRESS_TCP6_LISTEN),
link(UDP-LISTEN)(ADDRESS_UDP_LISTEN),
link(UNIX-LISTEN)(ADDRESS_UNIX_LISTEN),
link(OPENSSL-LISTEN)(ADDRESS_OPENSSL_LISTEN)
label(ADDRESS_TCP4_LISTEN)dit(bf(tt(TCP4-LISTEN:)))
Like link(TCP-LISTEN)(ADDRESS_TCP_LISTEN), but only supports IPv4
protocol (link(example)(EXAMPLE_ADDRESS_TCP4_LISTEN)).nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(LISTEN)(GROUP_LISTEN),link(CHILD)(GROUP_CHILD),link(RANGE)(GROUP_RANGE),link(IP4)(GROUP_IP4),link(TCP)(GROUP_TCP),link(RETRY)(GROUP_RETRY) nl()
label(ADDRESS_TCP6_LISTEN)dit(bf(tt(TCP6-LISTEN:)))
Like link(TCP-LISTEN)(ADDRESS_TCP_LISTEN), but only supports IPv6
protocol.nl()
Additional useful option:
link(ipv6only)(OPTION_IPV6_V6ONLY)nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(LISTEN)(GROUP_LISTEN),link(CHILD)(GROUP_CHILD),link(RANGE)(GROUP_RANGE),link(IP6)(GROUP_IP6),link(TCP)(GROUP_TCP),link(RETRY)(GROUP_RETRY) nl()
label(ADDRESS_TUN)dit(bf(tt(TUN:/)))
Creates a Linux TUN/TAP device and assignes to it the address and netmask
defined by the parameters. The resulting network interface is ready for use
by other processes; socat serves its "wire side". This address requires read
and write access to the tunnel cloning device, usually code(/dev/net/tun).
nl()
Option groups: link(FD)(GROUP_FD),link(NAMED)(GROUP_NAMED),link(OPEN)(GROUP_OPEN),link(TUN)(GROUP_TUN) nl()
Useful options:
link(iff-up)(OPTION_IFF_UP),
link(tun-device)(OPTION_TUN_DEVICE),
link(tun-name)(OPTION_TUN_NAME),
link(tun-type)(OPTION_TUN_TYPE),
link(iff-no-pi)(OPTION_IFF_NO_PI) nl()
See also:
link(ip-recv)(ADDRESS_IP_RECV)
label(ADDRESS_UDP_CONNECT)dit(bf(tt(UDP::)))
Connects to [link(UDP service)(TYPE_UDP_SERVICE)] on
[link(IP address)(TYPE_IP_ADDRESS)] using UDP/IP version 4 or 6
depending on address specification, name resolution, or option
link(pf)(OPTION_PROTOCOL_FAMILY).nl()
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.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6) nl()
Useful options:
link(ttl)(OPTION_TTL),
link(tos)(OPTION_TOS),
link(bind)(OPTION_BIND),
link(sourceport)(OPTION_SOURCEPORT),
link(pf)(OPTION_PROTOCOL_FAMILY)nl()
See also:
link(UDP4)(ADDRESS_UDP4_CONNECT),
link(UDP6)(ADDRESS_UDP6_CONNECT),
link(UDP-LISTEN)(ADDRESS_UDP_LISTEN),
link(TCP)(ADDRESS_TCP_CONNECT),
link(IP)(ADDRESS_IP_SENDTO)
label(ADDRESS_UDP4_CONNECT)dit(bf(tt(UDP4::)))
Like link(UDP)(ADDRESS_UDP_CONNECT), but only supports IPv4 protocol.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4) nl()
label(ADDRESS_UDP6_CONNECT)dit(bf(tt(UDP6::)))
Like link(UDP)(ADDRESS_UDP_CONNECT), but only supports IPv6 protocol.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP6)(GROUP_IP6) nl()
label(ADDRESS_UDP_DATAGRAM)dit(bf(tt(UDP-DATAGRAM::)))
Sends outgoing data to the specified address which may in particular be a
broadcast or multicast address. Packets arriving on the local socket are
checked for the correct remote port and if their source addresses match
eventual link(RANGE)(OPTION_RANGE) or link(TCPWRAP)(OPTION_TCPWRAPPERS)
options. This address type can for example be used for implementing
symmetric or asymmetric broadcast or multicast communications.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6),link(RANGE)(GROUP_RANGE) nl()
Useful options:
link(range)(OPTION_RANGE),
link(tcpwrap)(OPTION_TCPWRAPPERS),
link(broadcast)(OPTION_SO_BROADCAST),
link(ip-multicast-loop)(OPTION_IP_MULTICAST_LOOP),
link(ip-multicast-ttl)(OPTION_IP_MULTICAST_TTL),
link(ip-multicast-if)(OPTION_IP_MULTICAST_IF),
link(ip-add-membership)(OPTION_IP_ADD_MEMBERSHIP),
link(ttl)(OPTION_TTL),
link(tos)(OPTION_TOS),
link(bind)(OPTION_BIND),
link(sourceport)(OPTION_SOURCEPORT),
link(pf)(OPTION_PROTOCOL_FAMILY)nl()
See also:
link(UDP4-DATAGRAM)(ADDRESS_UDP4_DATAGRAM),
link(UDP6-DATAGRAM)(ADDRESS_UDP6_DATAGRAM),
link(UDP-SENDTO)(ADDRESS_UDP_SENDTO),
link(UDP-RECVFROM)(ADDRESS_UDP_RECVFROM),
link(UDP-RECV)(ADDRESS_UDP_RECV),
link(UDP-CONNECT)(ADDRESS_UDP_CONNECT),
link(UDP-LISTEN)(ADDRESS_UDP_LISTEN),
link(IP-DATAGRAM)(ADDRESS_IP_DATAGRAM)
label(ADDRESS_UDP4_DATAGRAM)dit(bf(tt(UDP4-DATAGRAM::)))
Like link(UDP-DATAGRAM)(ADDRESS_UDP_DATAGRAM), but only supports IPv4
protocol (link(example1)(EXAMPLE_ADDRESS_UDP4_BROADCAST_CLIENT),
link(example2)(EXAMPLE_ADDRESS_UDP4_MULTICAST)).nl()
Option groups: link(FD)(GROUP_FD), link(SOCKET)(GROUP_SOCKET),
link(IP4)(GROUP_IP4), link(RANGE)(GROUP_RANGE)
label(ADDRESS_UDP6_DATAGRAM)dit(bf(tt(UDP6-DATAGRAM::)))
Like link(UDP-DATAGRAM)(ADDRESS_UDP_DATAGRAM), but only supports IPv6
protocol.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),
link(IP6)(GROUP_IP6),link(RANGE)(GROUP_RANGE)
label(ADDRESS_UDP_LISTEN)dit(bf(tt(UDP-LISTEN:)))
Waits for a UDP/IP packet arriving on
[link(UDP service)(TYPE_UDP_SERVICE)] and `connects' back to sender.
The accepted IP version is 4 or the one specified with option
link(pf)(OPTION_PROTOCOL_FAMILY).
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.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(LISTEN)(GROUP_LISTEN),link(CHILD)(GROUP_CHILD),link(RANGE)(GROUP_RANGE),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6) nl()
Useful options:
link(fork)(OPTION_FORK),
link(bind)(OPTION_BIND),
link(range)(OPTION_RANGE),
link(pf)(OPTION_PROTOCOL_FAMILY) nl()
See also:
link(UDP)(ADDRESS_UDP_CONNECT),
link(UDP4-LISTEN)(ADDRESS_UDP4_LISTEN),
link(UDP6-LISTEN)(ADDRESS_UDP6_LISTEN),
link(TCP-LISTEN)(ADDRESS_TCP_LISTEN)
label(ADDRESS_UDP4_LISTEN)dit(bf(tt(UDP4-LISTEN:)))
Like link(UDP-LISTEN)(ADDRESS_UDP_LISTEN), but only support IPv4
protocol.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(LISTEN)(GROUP_LISTEN),link(CHILD)(GROUP_CHILD),link(RANGE)(GROUP_RANGE),link(IP4)(GROUP_IP4) nl()
label(ADDRESS_UDP6_LISTEN)dit(bf(tt(UDP6-LISTEN:)))
Like link(UDP-LISTEN)(ADDRESS_UDP_LISTEN), but only support IPv6
protocol.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(LISTEN)(GROUP_LISTEN),link(CHILD)(GROUP_CHILD),link(RANGE)(GROUP_RANGE),link(IP6)(GROUP_IP6) nl()
label(ADDRESS_UDP_SENDTO)dit(bf(tt(UDP-SENDTO::)))
Communicates with the specified peer socket, defined by [link(UDP
service)(TYPE_UDP_SERVICE)] on
[link(IP address)(TYPE_IP_ADDRESS)], using UDP/IP version 4 or 6
depending on address specification, name resolution, or option
link(pf)(OPTION_PROTOCOL_FAMILY). It sends packets to and receives packets
from that peer socket only.
This address effectively implements a datagram client.
It works well with socat UDP-RECVFROM and UDP-RECV address peers.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6) nl()
Useful options:
link(ttl)(OPTION_TTL),
link(tos)(OPTION_TOS),
link(bind)(OPTION_BIND),
link(sourceport)(OPTION_SOURCEPORT),
link(pf)(OPTION_PROTOCOL_FAMILY)nl()
See also:
link(UDP4-SENDTO)(ADDRESS_UDP4_SENDTO),
link(UDP6-SENDTO)(ADDRESS_UDP6_SENDTO),
link(UDP-RECVFROM)(ADDRESS_UDP_RECVFROM),
link(UDP-RECV)(ADDRESS_UDP_RECV),
link(UDP-CONNECT)(ADDRESS_UDP_CONNECT),
link(UDP-LISTEN)(ADDRESS_UDP_LISTEN),
link(IP-SENDTO)(ADDRESS_IP_SENDTO)
label(ADDRESS_UDP4_SENDTO)dit(bf(tt(UDP4-SENDTO::)))
Like link(UDP-SENDTO)(ADDRESS_UDP_SENDTO), but only supports IPv4
protocol.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4)
label(ADDRESS_UDP6_SENDTO)dit(bf(tt(UDP6-SENDTO::)))
Like link(UDP-SENDTO)(ADDRESS_UDP_SENDTO), but only supports IPv6
protocol.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP6)(GROUP_IP6)
label(ADDRESS_UDP_RECVFROM)dit(bf(tt(UDP-RECVFROM:)))
Creates a UDP socket on [link(UDP service)(TYPE_UDP_SERVICE)] using
UDP/IP version 4 or 6
depending on option link(pf)(OPTION_PROTOCOL_FAMILY).
It receives one packet from an unspecified peer and may send one or more
answer packets to that peer. This mode is particularly useful with fork
option
where each arriving packet - from arbitrary peers - is handled by its own sub
process. This allows a behaviour similar to typical UDP based servers like ntpd
or named. This address works well with socat SENDTO address peers.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6),link(CHILD)(GROUP_CHILD),link(RANGE)(GROUP_RANGE) nl()
Useful options:
link(fork)(OPTION_FORK),
link(ttl)(OPTION_TTL),
link(tos)(OPTION_TOS),
link(bind)(OPTION_BIND),
link(sourceport)(OPTION_SOURCEPORT),
link(pf)(OPTION_PROTOCOL_FAMILY)nl()
See also:
link(UDP4-RECVFROM)(ADDRESS_UDP4_RECVFROM),
link(UDP6-RECVFROM)(ADDRESS_UDP6_RECVFROM),
link(UDP-SENDTO)(ADDRESS_UDP_SENDTO),
link(UDP-RECV)(ADDRESS_UDP_RECV),
link(UDP-CONNECT)(ADDRESS_UDP_CONNECT),
link(UDP-LISTEN)(ADDRESS_UDP_LISTEN),
link(IP-RECVFROM)(ADDRESS_IP_RECVFROM),
link(UNIX-RECVFROM)(ADDRESS_UNIX_RECVFROM)
label(ADDRESS_UDP4_RECVFROM)dit(bf(tt(UDP4-RECVFROM:)))
Like link(UDP-RECVFROM)(ADDRESS_UDP_RECVFROM), but only supports IPv4 protocol.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(CHILD)(GROUP_CHILD),link(RANGE)(GROUP_RANGE)
label(ADDRESS_UDP6_RECVFROM)dit(bf(tt(UDP6-RECVFROM:)))
Like link(UDP-RECVFROM)(ADDRESS_UDP_RECVFROM), but only supports IPv6 protocol.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP6)(GROUP_IP6),link(CHILD)(GROUP_CHILD),link(RANGE)(GROUP_RANGE)
label(ADDRESS_UDP_RECV)dit(bf(tt(UDP-RECV:)))
Creates a UDP socket on [link(UDP service)(TYPE_UDP_SERVICE)] using UDP/IP version 4 or 6
depending on option link(pf)(OPTION_PROTOCOL_FAMILY).
It receives packets from multiple unspecified peers and merges the data.
No replies are possible. It works well with, e.g., socat UDP-SENDTO address peers; it behaves similar to a syslog server.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(IP6)(GROUP_IP6),link(RANGE)(GROUP_RANGE) nl()
Useful options:
link(fork)(OPTION_FORK),
link(pf)(OPTION_PROTOCOL_FAMILY),
link(bind)(OPTION_BIND),
link(sourceport)(OPTION_SOURCEPORT),
link(ttl)(OPTION_TTL),
link(tos)(OPTION_TOS)nl()
See also:
link(UDP4-RECV)(ADDRESS_UDP4_RECV),
link(UDP6-RECV)(ADDRESS_UDP6_RECV),
link(UDP-SENDTO)(ADDRESS_UDP_SENDTO),
link(UDP-RECVFROM)(ADDRESS_UDP_RECVFROM),
link(UDP-CONNECT)(ADDRESS_UDP_CONNECT),
link(UDP-LISTEN)(ADDRESS_UDP_LISTEN),
link(IP-RECV)(ADDRESS_IP_RECV),
link(UNIX-RECV)(ADDRESS_UNIX_RECV)
label(ADDRESS_UDP4_RECV)dit(bf(tt(UDP4-RECV:)))
Like link(UDP-RECV)(ADDRESS_UDP_RECV), but only supports IPv4 protocol.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP4)(GROUP_IP4),link(RANGE)(GROUP_RANGE)
label(ADDRESS_UDP6_RECV)dit(bf(tt(UDP6-RECV:)))
Like link(UDP-RECV)(ADDRESS_UDP_RECV), but only supports IPv6 protocol.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),link(IP6)(GROUP_IP6),link(RANGE)(GROUP_RANGE)
label(ADDRESS_UNIX_CONNECT)dit(bf(tt(UNIX-CONNECT:)))
Connects to link()(TYPE_FILENAME) assuming it is a unixdomain()
socket.
If does not exist, this is an error;
if is not a unixdomain() socket, this is an error;
if is a unixdomain() socket, but no process is listening, this is
an error.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),
link(NAMED)(GROUP_NAMED),link(RETRY)(GROUP_RETRY),
link(UNIX)(GROUP_SOCK_UNIX) nl())
Useful options:
link(bind)(OPTION_BIND)nl()
See also:
link(UNIX-LISTEN)(ADDRESS_UNIX_LISTEN),
link(UNIX-SENDTO)(ADDRESS_UNIX_SENDTO),
link(TCP)(ADDRESS_TCP_CONNECT)
label(ADDRESS_UNIX_LISTEN)dit(bf(tt(UNIX-LISTEN:)))
Listens on link()(TYPE_FILENAME) using a unixdomain() stream
socket and accepts a connection.
If exists and is not a socket, this is an error.
If exists and is a unixdomain() socket, binding to the address
fails (use option link(unlink-early)(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 link(unlink-close)(OPTION_UNLINK_CLOSE)) (link(example)(EXAMPLE_ADDRESS_UNIX_LISTEN)).nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),
link(NAMED)(GROUP_NAMED),link(LISTEN)(GROUP_LISTEN),
link(CHILD)(GROUP_CHILD),link(RETRY)(GROUP_RETRY),
link(UNIX)(GROUP_SOCK_UNIX) nl()
Useful options:
link(fork)(OPTION_FORK),
link(umask)(OPTION_UMASK),
link(mode)(OPTION_MODE),
link(user)(OPTION_USER),
link(group)(OPTION_GROUP),
link(unlink-early)(OPTION_UNLINK_EARLY)nl()
See also:
link(UNIX-CONNECT)(ADDRESS_UNIX_CONNECT),
link(UNIX-RECVFROM)(ADDRESS_UNIX_RECVFROM),
link(UNIX-RECV)(ADDRESS_UNIX_RECV),
link(TCP-LISTEN)(ADDRESS_TCP4_LISTEN)
label(ADDRESS_UNIX_SENDTO)dit(bf(tt(UNIX-SENDTO:)))
Communicates with the specified peer socket, defined by [link()(TYPE_FILENAME)] assuming it is a unixdomain() datagram socket.
It sends packets to and receives packets from that peer socket only.
It works well with socat UNIX-RECVFROM and UNIX-RECV address peers.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),
link(NAMED)(GROUP_NAMED),link(UNIX)(GROUP_SOCK_UNIX)nl()
Useful options:
link(bind)(OPTION_BIND)nl()
See also:
link(UNIX-RECVFROM)(ADDRESS_UNIX_RECVFROM),
link(UNIX-RECV)(ADDRESS_UNIX_RECV),
link(UNIX-CONNECT)(ADDRESS_UNIX_CONNECT),
link(UDP-SENDTO)(ADDRESS_UDP_SENDTO),
link(IP-SENDTO)(ADDRESS_IP_SENDTO)
label(ADDRESS_UNIX_RECVFROM)dit(bf(tt(UNIX-RECVFROM:)))
Creates a unixdomain() datagram socket [link()(TYPE_FILENAME)].
Receives one packet and may send one or more answer packets to that peer.
This mode is particularly useful with fork option where each arriving packet - from arbitrary peers - is handled by its own sub process.
This address works well with socat UNIX-SENDTO address peers.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),
link(NAMED)(GROUP_NAMED),link(CHILD)(GROUP_CHILD),
link(UNIX)(GROUP_SOCK_UNIX) nl()
Useful options:
link(fork)(OPTION_FORK)nl()
See also:
link(UNIX-SENDTO)(ADDRESS_UNIX_SENDTO),
link(UNIX-RECV)(ADDRESS_UNIX_RECV),
link(UNIX-LISTEN)(ADDRESS_UNIX_LISTEN),
link(UDP-RECVFROM)(ADDRESS_UDP_RECVFROM),
link(IP-RECVFROM)(ADDRESS_IP_RECVFROM)
label(ADDRESS_UNIX_RECV)dit(bf(tt(UNIX-RECV:)))
Creates a unixdomain() datagram socket [link()(TYPE_FILENAME)].
Receives packets from multiple unspecified peers and merges the data.
No replies are possible. It can be, e.g., addressed by socat UNIX-SENDTO address peers.
It behaves similar to a syslog server.
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),
link(NAMED)(GROUP_NAMED),link(UNIX)(GROUP_SOCK_UNIX) nl()
See also:
link(UNIX-SENDTO)(ADDRESS_UNIX_SENDTO),
link(UNIX-RECVFROM)(ADDRESS_UNIX_RECVFROM),
link(UNIX-LISTEN)(ADDRESS_UNIX_LISTEN),
link(UDP-RECV)(ADDRESS_UDP_RECV),
link(IP-RECV)(ADDRESS_IP_RECV)
label(ADDRESS_UNIX_CLIENT)dit(bf(tt(UNIX-CLIENT:)))
Communicates with the specified peer socket, defined by
[link()(TYPE_FILENAME)] assuming it is a unixdomain() socket.
It first tries to connect and, if that fails, assumes it is a datagram
socket, thus supporting both types.nl()
Option groups: link(FD)(GROUP_FD),link(SOCKET)(GROUP_SOCKET),
link(NAMED)(GROUP_NAMED),link(UNIX)(GROUP_SOCK_UNIX) nl()
Useful options:
link(bind)(OPTION_BIND)nl()
See also:
link(UNIX-CONNECT)(ADDRESS_UNIX_CONNECT),
link(UNIX-SENDTO)(ADDRESS_UNIX_SENDTO),
link(GOPEN)(ADDRESS_GOPEN)
dit(bf(tt(ABSTRACT-CONNECT:)))
dit(bf(tt(ABSTRACT-LISTEN:)))
dit(bf(tt(ABSTRACT-SENDTO:)))
dit(bf(tt(ABSTRACT-RECVFROM:)))
dit(bf(tt(ABSTRACT-RECV:)))
dit(bf(tt(ABSTRACT-CLIENT:)))
The ABSTRACT addresses are almost identical to the related UNIX addresses
except that they do not address file system based sockets but an alternate
unixdomain() address space. To archieve this the socket address strings are
prefixed with "\0" internally. This feature is available (only?) on Linux.
Option groups are the same as with the related UNIX addresses, except that
the ABSTRACT addresses are not member of the NAMED group.
enddit()
label(ADDRESS_OPTIONS)
manpagesection(ADDRESS OPTIONS)
Address options can be applied to address specifications to influence the
process of opening the addresses and the
properties of the resulting data channels.
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 em(option groups) 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 link(option -g)(option_g)).
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.
COMMENT(Options that trigger a call with
trivial parameters are described with type BOOL which might be misleading.)
Some address options manipulate parameters of system calls;
e.g., option sync sets the code(O_SYNC) flag with the code(open()) call.
Other options cause a system or library call; e.g., with option `ttl=value'
the code(setsockopt(fd, SOL_IP, IP_TTL, value, sizeof(int))) call is applied.
Other
options set internal socat() 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 code(chroot()) call.
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, socat() has
built in an em(option phase) 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.
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 code(setsockopt()) cause multiple
invocations. With options that set parameters for a required call like
code(open())
or set internal flags, the value of the last option occurrence is effective.
The existence or semantics of many options are system dependent. Socat()
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.
The following paragraphs introduce just the more common address options. For
a more comprehensive reference and to find information about canonical option
names, alias names, option phases, and platforms see file file(xio.help).
nl() nl()
startdit()enddit()nl()
label(GROUP_FD)em(bf(FD option group))
This option group contains options that are applied to a unix()
style file descriptor, no matter how it was generated.
Because all current socat() address types are file descriptor based, these
options may be applied to any address. nl()
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.
startdit()
label(OPTION_CLOEXEC)dit(bf(tt(cloexec=)))
Sets the code(FD_CLOEXEC) flag with the code(fcntl()) system call to value
link()(TYPE_BOOL). If set,
the file descriptor is closed on code(exec()) family function calls. Socat()
internally handles
this flag for the fds it controls, so in most cases there will be no need to
apply this option.
label(OPTION_SETLK_WR)dit(bf(tt(setlk)))
Tries to set a discretionary write lock to the whole file using the code(fcntl(fd,
F_SETLK, ...)) system call. If the file is already locked, this call results
in an error.
On Linux, when the file permissions for group are "S" (g-x,g+s), and the
file system is locally mounted with the "mand" option, the lock is
mandatory, i.e. prevents other processes from opening the file.
label(OPTION_SETLKW_WR)dit(bf(tt(setlkw)))
Tries to set a discretionary waiting write lock to the whole file using the
code(fcntl(fd, F_SETLKW, ...)) system call. If the file is already locked,
this call blocks.
See option link(setlk)(OPTION_SETLK_WR) for information about making this
lock mandatory.
label(OPTION_SETLK_RD)dit(bf(tt(setlk-rd)))
Tries to set a discretionary read lock to the whole file using the code(fcntl(fd,
F_SETLK, ...)) system call. If the file is already write locked, this call
results in an error.
See option link(setlk)(OPTION_SETLK_WR) for information about making this
lock mandatory.
label(OPTION_SETLKW_RD)dit(bf(tt(setlkw-rd)))
Tries to set a discretionary waiting read lock to the whole file using the
code(fcntl(fd, F_SETLKW, ...)) system call. If the file is already write
locked, this call blocks.
See option link(setlk)(OPTION_SETLK_WR) for information about making this
lock mandatory.
label(OPTION_FLOCK_EX)dit(bf(tt(flock-ex)))
Tries to set a blocking exclusive advisory lock to the file using the
code(flock(fd, LOCK_EX)) system call. Socat() hangs in this call if the file
is locked by another process.
label(OPTION_FLOCK_EX_NB)dit(bf(tt(flock-ex-nb)))
Tries to set a nonblocking exclusive advisory lock to the file using the
code(flock(fd, LOCK_EX|LOCK_NB)) system call. If the file is already locked,
this option results in an error.
label(OPTION_FLOCK_SH)dit(bf(tt(flock-sh)))
Tries to set a blocking shared advisory lock to the file using the
code(flock(fd, LOCK_SH)) system call. Socat() hangs in this call if the file
is locked by another process.
label(OPTION_FLOCK_SH_NB)dit(bf(tt(flock-sh-nb)))
Tries to set a nonblocking shared advisory lock to the file using the
code(flock(fd, LOCK_SH|LOCK_NB)) system call. If the file is already locked,
this option results in an error.
label(OPTION_LOCK)dit(bf(tt(lock)))
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 used.
label(OPTION_USER)dit(bf(tt(user=)))
Sets the link()(TYPE_USER) (owner) of the stream.
If the address is member of the NAMED option group,
socat() uses the code(chown()) system call after opening the
file or binding to the unixdomain() socket (race condition!).
Without filesystem entry, socat() sets the user of the stream
using the code(fchown()) system call.
These calls might require root privilege.
label(OPTION_USER_LATE)dit(bf(tt(user-late=)))
Sets the owner of the fd to link()(TYPE_USER) with the code(fchown())
system call after opening
or connecting the channel.
This is useful only on file system entries.
label(OPTION_GROUP)dit(bf(tt(group=)))
Sets the link()(TYPE_GROUP) of the stream.
If the address is member of the NAMED option group,
socat() uses the code(chown()) system call after opening the
file or binding to the unixdomain() socket (race condition!).
Without filesystem entry, socat() sets the group of the stream
with the code(fchown()) system call.
These calls might require group membership or root privilege.
label(OPTION_GROUP_LATE)dit(bf(tt(group-late=)))
Sets the group of the fd to link()(TYPE_GROUP) with the
code(fchown()) system call after opening
or connecting the channel.
This is useful only on file system entries.
label(OPTION_MODE)dit(bf(tt(mode=)))
Sets the [link(mode_t)(TYPE_MODE_T)] (permissions) of the stream.
If the address is member of the NAMED option group and
uses the code(open()) or code(creat()) call, the mode is applied with these.
If the address is member of the NAMED option group without using these
system calls, socat() uses the code(chmod()) system call after opening the
filesystem entry or binding to the unixdomain() socket (race condition!).
Otherwise, socat() sets the mode of the stream
using code(fchmod()).
These calls might require ownership or root privilege.
label(OPTION_PERM_LATE)dit(bf(tt(perm-late=)))
Sets the permissions of the fd to value
[link(mode_t)(TYPE_MODE_T)] using the code(fchmod()) system call after
opening or connecting the channel.
This is useful only on file system entries.
label(OPTION_APPEND)dit(bf(tt(append=)))
Always writes data to the actual end of file.
If the address is member of the OPEN option group,
socat() uses the code(O_APPEND) flag with the code(open()) system call
(link(example)(EXAMPLE_OPTION_APPEND)).
Otherwise, socat() applies the code(fcntl(fd, F_SETFL, O_APPEND)) call.
label(OPTION_NONBLOCK)dit(bf(tt(nonblock=)))
Tries to open or use file in nonblocking mode. Its only effects are that the
code(connect()) 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,
socat() uses the code(O_NONBLOCK) flag with the code(open()) system call.
Otherwise, socat() applies the code(fcntl(fd, F_SETFL, O_NONBLOCK)) call.
COMMENT(label(OPTION_NDELAY)dit(bf(tt(ndelay=)))
Tries to open or use file in nonblocking mode. Has no effect because socat()
works with code(select()).)
COMMENT(label(OPTION_ASYNC)dit(bf(tt(async=)))
Enables SIGIO for this fd. Has no effect, because socat() ignores SIGIO.)
label(OPTION_O_BINARY)dit(bf(tt(binary)))
Opens the file in binary mode to avoid implicit line terminator
conversions (Cygwin).
label(OPTION_O_TEXT)dit(bf(tt(text)))
Opens the file in text mode to force implicit line terminator conversions
(Cygwin).
label(OPTION_O_NOINHERIT)dit(bf(tt(noinherit)))
Does not keep this file open in a spawned process (Cygwin).
label(OPTION_COOL_WRITE)dit(bf(tt(cool-write)))
Takes it easy when write fails with EPIPE or ECONNRESET and logs the message
with em(notice) level instead of em(error).
This prevents the log file from being filled with useless error messages
when socat is used as a high volume server or proxy where clients often
abort the connection.nl()
This option is experimental.
label(OPTION_END_CLOSE)dit(bf(tt(end-close)))
Changes the (address dependent) method of ending a connection to just close
the file descriptors. This is useful when the connection is to be reused by
or shared with other processes (link(example)(EXAMPLE_END_CLOSE)).nl()
Normally, socket connections will be ended with tt(shutdown(2)) which
terminates the socket even if it is shared by multiple processes.
tt(close(2)) "unlinks" the socket from the process but keeps it active as
long as there are still links from other processes.nl()
Similarly, when an address of type EXEC or SYSTEM is ended, socat usually
will explicitely kill the sub process. With this option, it will just close
the file descriptors.
enddit()
startdit()enddit()nl()
label(GROUP_NAMED)em(bf(NAMED option group))
These options work on file system entries.nl()
See also options link(user)(OPTION_USER), link(group)(OPTION_GROUP), and
link(mode)(OPTION_MODE).
startdit()
label(OPTION_USER_EARLY)dit(bf(tt(user-early=)))
Changes the link()(TYPE_USER) (owner) of the file system entry before
accessing it, using the
code(chown()) system call. This call might require root privilege.
label(OPTION_GROUP_EARLY)dit(bf(tt(group-early=)))
Changes the link()(TYPE_GROUP) of the file system entry before
accessing it, using the
code(chown()) system call. This call might require group membership or root
privilege.
label(OPTION_PERM_EARLY)dit(bf(tt(perm-early=)))
Changes the [link(mode_t)(TYPE_MODE_T)] of the file system entry
before accessing it, using the
code(chmod()) system call. This call might require ownership or root
privilege.
label(OPTION_UMASK)dit(bf(tt(umask=)))
Sets the umask of the process to [link(mode_t)(TYPE_MODE_T)] before
accessing the file system entry (useful
with unixdomain() sockets!). This call might affect all further operations
of the socat() process!
label(OPTION_UNLINK_EARLY)dit(bf(tt(unlink-early)))
Unlinks (removes) the file before opening it and even before applying
user-early etc.
label(OPTION_UNLINK)dit(bf(tt(unlink)))
Unlinks (removes) the file before accessing it, but after user-early etc.
label(OPTION_UNLINK_LATE)dit(bf(tt(unlink-late)))
Unlinks (removes) the file after opening it to make it inaccessible for
other processes after a short race condition.
label(OPTION_UNLINK_CLOSE)dit(bf(tt(unlink-close)))
Removes the addresses file system entry when closing the address.
For link(named pipes)(ADDRESS_NAMED_PIPE),
link(listening unix domain sockets)(ADDRESS_UNIX_LISTEN),
and the link(symbolic links)(OPTION_SYMBOLIC_LINK) of link(pty addresses)(ADDRESS_PTY),
the default is 1; for link(created files)(ADDRESS_CREAT),
link(opened files)(ADDRESS_OPEN),
link(generic opened files)(ADDRESS_GOPEN), and
link(client unix domain sockets)(ADDRESS_UNIX_CONNECT) the default is 0.
enddit()
startdit()enddit()nl()
label(GROUP_OPEN)em(bf(OPEN option group))
The OPEN group options allow to set flags with the code(open()) system call.
E.g., option `creat' sets the code(O_CREAT) flag.nl()
See also options link(append)(OPTION_APPEND) and
link(nonblock)(OPTION_NONBLOCK).
startdit()
label(OPTION_CREAT)dit(bf(tt(creat=)))
Creates the file if it does not exist (link(example)(EXAMPLE_OPTION_CREAT)).
label(OPTION_DSYNC)dit(bf(tt(dsync=)))
Blocks code(write()) calls until metainfo is physically written to media.
label(OPTION_EXCL)dit(bf(tt(excl=)))
With option creat, if file exists this is an error.
label(OPTION_LARGEFILE)dit(bf(tt(largefile=)))
On 32 bit systems, allows a file larger than 2^31 bytes.
label(OPTION_O_NOATIME)dit(bf(tt(noatime)))
Sets the O_NOATIME options, so reads do not change the access timestamp.
label(OPTION_NOCTTY)dit(bf(tt(noctty=)))
Does not make this file the controlling terminal.
label(OPTION_NOFOLLOW)dit(bf(tt(nofollow=)))
Does not follow symbolic links.
label(OPTION_NSHARE)dit(bf(tt(nshare=)))
Does not allow to share this file with other processes.
label(OPTION_RSHARE)dit(bf(tt(rshare=)))
Does not allow other processes to open this file for writing.
label(OPTION_RSYNC)dit(bf(tt(rsync=)))
Blocks code(write()) until metainfo is physically written to media.
label(OPTION_SYNC)dit(bf(tt(sync=)))
Blocks code(write()) until data is physically written to media.
COMMENT(label(OPTION_DEFER)dit(bf(tt(defer=)))
Temporarily stores write data in paging space.)
COMMENT(label(OPTION_DELAY)dit(bf(tt(delay=)))
Blocks code(open()) until share conditions are fulfilled.)
COMMENT(label(OPTION_DIRECT)dit(bf(tt(direct=))))
COMMENT(label(OPTION_DIRECTORY)dit(bf(tt(directory=)))
Fails if file is not a directory. Not useful with socat().)
label(OPTION_RDONLY)dit(bf(tt(rdonly=)))
Opens the file for reading only.
COMMENT(label(OPTION_RDWR)dit(bf(tt(rdwr=)))
Opens the file for reading and writing.)
label(OPTION_WRONLY)dit(bf(tt(wronly=)))
Opens the file for writing only.
label(OPTION_TRUNC)dit(bf(tt(trunc)))
Truncates the file to size 0 during opening it.
enddit()
startdit()enddit()nl()
label(GROUP_REG)em(bf(REG and BLK option group))
These options are usually applied to a unix() file descriptor, but their
semantics make sense only on a file supporting random access.
startdit()
label(OPTION_SEEK)dit(bf(tt(seek=)))
Applies the code(lseek(fd, , SEEK_SET)) (or code(lseek64)) system
call, thus positioning the file pointer absolutely to
[link(off_t)(TYPE_OFF) or link(off64_t)(TYPE_OFF64)].
label(OPTION_SEEK_CUR)dit(bf(tt(seek-cur=)))
Applies the code(lseek(fd, , SEEK_CUR)) (or code(lseek64)) system
call, thus positioning the file pointer [link(off_t)(TYPE_OFF) or
link(off64_t)(TYPE_OFF64)] bytes relatively to its current position (which
is usually 0).
label(OPTION_SEEK_END)dit(bf(tt(seek-end=)))
Applies the code(lseek(fd, , SEEK_END)) (or code(lseek64)) system
call, thus positioning the file pointer [link(off_t)(TYPE_OFF) or
link(off64_t)(TYPE_OFF64)] bytes relatively to the files current end.
label(OPTION_FTRUNCATE)dit(bf(tt(ftruncate=)))
Applies the code(ftruncate(fd, ))
(or code(ftruncate64) if available) system call, thus
truncating the file at the position [link(off_t)(TYPE_OFF) or
link(off64_t)(TYPE_OFF64)].
label(OPTION_EXT2_SECRM_FL)dit(bf(tt(secrm=)))
label(OPTION_EXT2_UNRM)dit(bf(tt(unrm=)))
label(OPTION_EXT2_COMPR)dit(bf(tt(compr=)))
label(OPTION_EXT2_SYNC)dit(bf(tt(ext2-sync=)))
label(OPTION_EXT2_IMMUTABLE)dit(bf(tt(immutable=)))
label(OPTION_EXT2_APPEND)dit(bf(tt(ext2-append=)))
label(OPTION_EXT2_NODUMP)dit(bf(tt(nodump=)))
label(OPTION_EXT2_NOATIME)dit(bf(tt(ext2-noatime=)))
label(OPTION_EXT2_JOURNAL_DATA)dit(bf(tt(journal-data=)))
label(OPTION_EXT2_NOTAIL)dit(bf(tt(notail=)))
label(OPTION_EXT2_DIRSYNC)dit(bf(tt(dirsync=)))
These options change non standard file attributes on operating systems and
file systems that support these features, like Linux with ext2fs,
ext3fs, or reiserfs. See man 1 chattr for information on these options.
Please note that there might be a race condition between creating the file
and applying these options.
enddit()
startdit()enddit()nl()
label(GROUP_PROCESS)em(bf(PROCESS option group))
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.
startdit()
label(OPTION_CHROOT)dit(bf(tt(chroot=)))
Performs a code(chroot()) operation to link()(TYPE_DIRECTORY)
after processing the address (link(example)(EXAMPLE_OPTION_CHROOT)). This call might require root privilege.
label(OPTION_CHROOT_EARLY)dit(bf(tt(chroot-early=)))
Performs a code(chroot()) operation to link()(TYPE_DIRECTORY)
before opening the address. This call might require root privilege.
label(OPTION_SETGID)dit(bf(tt(setgid=)))
Changes the primary link()(TYPE_GROUP) of the process after
processing the address. This call might require root privilege.
label(OPTION_SETGID_EARLY)dit(bf(tt(setgid-early=)))
Changes the primary link()(TYPE_GROUP) of the process before opening
the address. This call might require root privilege.
label(OPTION_SETUID)dit(bf(tt(setuid=)))
Changes the link()(TYPE_USER) (owner) of the process after processing
the address. This call might require root privilege.
label(OPTION_SETUID_EARLY)dit(bf(tt(setuid-early=)))
Changes the link()(TYPE_USER) (owner) of the process before opening
the address. This call might require root privilege.
label(OPTION_SUBSTUSER)dit(bf(tt(su=)))
Changes the link()(TYPE_USER) (owner) and groups of the process after
processing the address (link(example)(EXAMPLE_OPTION_SUBSTUSER)). This call might require root privilege.
label(OPTION_SUBSTUSER_DELAYED)dit(bf(tt(su-d=)))
Short name for bf(tt(substuser-delayed)).
Changes the link()(TYPE_USER)
(owner) and groups of the process after processing the address (link(example)(EXAMPLE_OPTION_SUBSTUSER_DELAYED)).
The user and his groups are retrieved em(before) a possible
code(chroot()). This call might require root privilege.
label(OPTION_SETPGID)dit(bf(tt(setpgid=)))
Makes the process a member of the specified process group
link()(TYPE_PID_T). If no value
is given, or if the value is 0 or 1, the process becomes leader of a new
process group.
label(OPTION_SETSID)dit(bf(tt(setsid)))
Makes the process the leader of a new session (link(example)(EXAMPLE_OPTION_SETSID)).
enddit()
startdit()enddit()nl()
label(GROUP_READLINE)em(bf(READLINE option group))
These options apply to the readline address type.
startdit()
label(OPTION_HISTORY)dit(bf(tt(history=)))
Reads and writes history from/to link()(TYPE_FILENAME) (link(example)(EXAMPLE_OPTION_HISTORY)).
label(OPTION_NOPROMPT)dit(bf(tt(noprompt)))
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.
label(OPTION_NOECHO)dit(bf(tt(noecho=)))
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.
(link(example)(EXAMPLE_OPTION_NOECHO))
label(OPTION_PROMPT)dit(bf(tt(prompt=)))
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.
enddit()
startdit()enddit()nl()
label(GROUP_APPLICATION)em(bf(APPLICATION option group))
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
link(PROXY)(ADDRESS_PROXY_CONNECT).
startdit()
label(OPTION_CR)dit(bf(tt(cr)))
Converts the default line termination character NL ('\n', 0x0a) to/from CR
('\r', 0x0d) when writing/reading on this channel.
label(OPTION_CRNL)dit(bf(tt(crnl)))
Converts the default line termination character NL ('\n', 0x0a) to/from CRNL
("\r\n", 0x0d0a) when writing/reading on this channel (link(example)(EXAMPLE_OPTION_CRNL)).
Note: socat simply strips all CR characters.
label(OPTION_IGNOREEOF)dit(bf(tt(ignoreeof)))
When EOF occurs on this channel, socat() ignores it and tries to read more
data (like "tail -f") (link(example)(EXAMPLE_OPTION_IGNOREEOF)).
label(OPTION_READBYTES)dit(bf(tt(readbytes=)))
socat() reads only so many bytes from this address (the address provides
only so many bytes for transfer and pretends to be at EOF afterwards).
Must be greater than 0.
label(OPTION_LOCKFILE)dit(bf(tt(lockfile=)))
If lockfile exists, exits with error. If lockfile does not exist, creates it
and continues, unlinks lockfile on exit.
label(OPTION_WAITLOCK)dit(bf(tt(waitlock=)))
If lockfile exists, waits until it disappears. When lockfile does not exist,
creates it and continues, unlinks lockfile on exit.
enddit()
startdit()enddit()nl()
label(GROUP_SOCKET)em(bf(SOCKET option group))
These options are intended for all kinds of sockets, e.g. IP or unixdomain(). Most are applied with a code(setsockopt()) call.
startdit()
label(OPTION_BIND)dit(bf(tt(bind=)))
Binds the socket to the given socket address using the code(bind()) system
call. The form of is socket domain dependent:
IP4 and IP6 allow the form [hostname|hostaddress][:(service|port)] (link(example)(EXAMPLE_OPTION_BIND_TCP4)),
unixdomain() sockets require link()(TYPE_FILENAME).
label(OPTION_CONNECT_TIMEOUT)dit(bf(tt(connect-timeout=)))
Abort the connection attempt after [link(timeval)(TYPE_TIMEVAL)]
with error status.
label(OPTION_INTERFACE)dit(bf(tt(interface=)))
Binds the socket to the given link()(TYPE_INTERFACE).
This option might require root privilege.
label(OPTION_SO_BROADCAST)dit(bf(tt(broadcast)))
For datagram sockets, allows sending to broadcast addresses and receiving
packets addressed to broadcast addresses.
label(OPTION_BSDCOMPAT)dit(bf(tt(bsdcompat)))
Emulates some (old?) bugs of the BSD socket implementation.
label(OPTION_DEBUG)dit(bf(tt(debug)))
Enables socket debugging.
label(OPTION_DONTROUTE)dit(bf(tt(dontroute)))
Only communicates with directly connected peers, does not use routers.
label(OPTION_KEEPALIVE)dit(bf(tt(keepalive)))
Enables sending keepalives on the socket.
label(OPTION_LINGER)dit(bf(tt(linger=)))
Blocks code(shutdown()) or code(close()) until data transfers have finished
or the given timeout [link(int)(TYPE_INT)] expired.
COMMENT(label(OPTION_NOREUSEADDR)dit(bf(tt(noreuseaddr)))
Set the code(SO_NOREUSEADDR) socket option.)
label(OPTION_OOBINLINE)dit(bf(tt(oobinline)))
Places out-of-band data in the input data stream.
label(OPTION_PRIORITY)dit(bf(tt(priority=)))
Sets the protocol defined [link()(TYPE_INT)] for outgoing
packets.
label(OPTION_RCVBUF)dit(bf(tt(rcvbuf=)))
Sets the size of the receive buffer after the code(socket()) call to
[link(int)(TYPE_INT)]. With TCP
sockets, this value corresponds to the socket's maximal window size.
label(OPTION_RCVBUF_LATE)dit(bf(tt(rcvbuf-late=)))
Sets the size of the receive buffer when the socket is already
connected to [link(int)(TYPE_INT)].
With TCP sockets, this value corresponds to the socket's
maximal window size.
label(OPTION_RCVLOWAT)dit(bf(tt(rcvlowat=)))
Specifies the minimum number of received bytes [link(int)(TYPE_INT)] until
the socket layer will pass the buffered data to socat().
label(OPTION_RCVTIMEO)dit(bf(tt(rcvtimeo=