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 address types), and because lots of
address options may be applied to the streams, socat can
be used for many different purposes.
Socat 是一个基于命令行的实用程序,用于建立两个双向字节流并在它们之间传输数据。由于这些流可以由大量不同类型的数据汇和源构建(请参阅地址类型),并且可以对这些流应用许多地址选项,因此 socat 可用于许多不同的目的。
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.
Filan 是一个实用程序,将有关其活动文件描述符的信息打印到标准输出。它已经为调试 socat 而编写,但也可能对其他目的有用。使用 -h 选项查找更多信息。
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.
Procan 是一个实用程序,用于将有关进程参数的信息打印到标准输出。它已经被编写用于更好地理解一些 UNIX 进程属性和调试 socat,但也可能对其他目的有用。
The life cycle of a socat instance typically consists of four phases.
一个 socat 实例的生命周期通常包括四个阶段。
In the init phase, the command line options are parsed and logging is
initialized.
在初始化阶段,解析命令行选项并初始化日志记录。
During the 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.
在打开阶段,socat 首先打开第一个地址,然后打开第二个地址。这些步骤通常是阻塞的;因此,特别是对于像 socks、连接请求或身份验证对话框这样复杂的地址类型,必须在下一步开始之前完成。
In the transfer phase, socat watches both streams' read and write file
descriptors via
select()
, and, when data is available on one side 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.
在传输阶段,socat 通过 select() 监视两个流的读取和写入文件描述符,当一侧有数据可用且可以写入另一侧时,socat 会读取数据,如果需要进行换行字符转换,则执行该操作,并将数据写入另一个流的写文件描述符,然后继续等待双向更多数据。
When one of the streams effectively reaches EOF, the 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.
当其中一个流有效地达到 EOF 时,关闭阶段开始。Socat 将 EOF 条件传输到另一个流,即尝试仅关闭其写入流,使其有机会优雅地终止。在一定时间内,socat 继续在另一个方向传输数据,然后关闭所有剩余通道并终止。
OPTIONS 选项
Socat 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.
Socat 提供了一些命令行选项,可以修改程序的行为。它们与所谓的地址选项无关,这些选项用作地址规范的一部分。
-V
Print version and available feature information to stdout, and exit.
打印版本和可用功能信息到标准输出,并退出。
-h | -?
Print a help text to stdout describing command line options and available address
types, and exit.
打印帮助文本到标准输出,描述命令行选项和可用地址类型,然后退出。
-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.
类似于 -h,再加上所有可用地址选项的简称列表。一些选项是平台相关的,因此此输出对于检查特定实现非常有帮助。
-hhh | -???
Like -hh, plus a list of all available address option names.
类似于 -hh,再加上所有可用地址选项名称的列表。
-d
Without this option, only fatal, error, and warning messages are printed;
applying this option also prints notice messages.
See DIAGNOSTICS for more information.
没有此选项,只会打印致命、错误和警告消息;应用此选项还会打印通知消息。有关更多信息,请参阅诊断。
-d0
With this option, only fatal and error messages are printed; this restores
the behaviour of socat up to version 1.7.4.
使用此选项,只会打印致命和错误消息;这恢复了 socat 版本 1.7.4 之前的行为。
-d -d | -dd | -d2
Prints fatal, error, warning, and notice messages.
打印致命、错误、警告和通知消息。
-d -d -d | -ddd | -d3
Prints fatal, error, warning, notice, and info messages.
打印致命错误、错误、警告、通知和信息消息。
-d -d -d -d | -dddd | -d4
Prints fatal, error, warning, notice, info, and debug
messages.
打印致命错误、错误、警告、通知、信息和调试消息。
-D
Logs information about file descriptors before starting the transfer phase.
在开始传输阶段之前记录有关文件描述符的信息。
--experimental
New features that are not well tested or are subject to change in the future
must me explicitely enabled using this option.
新功能必须经过充分测试或可能会在未来更改,必须使用此选项明确启用。
-ly[<facility>]
Writes messages to syslog instead of stderr; severity as defined with -d
option. With optional <facility>, the syslog type can
be selected, default is "daemon". Third party libraries might not obey this
option.
将消息写入 syslog 而不是 stderr;严重性由 -d 选项定义。使用可选的 <facility>,可以选择 syslog 类型,默认为 "daemon"。第三方库可能不遵守此选项。
-lf <logfile>
Writes messages to <logfile> [filename] instead of
stderr. Some third party libraries, in particular libwrap, might not obey
this option.
将消息写入 <logfile> [文件名] 而不是 stderr。某些第三方库,特别是 libwrap,可能不遵守此选项。
-ls
Writes messages to stderr (this is the default). Some third party libraries
might not obey this option, in particular libwrap appears to only log to
syslog.
将消息写入 stderr(这是默认设置)。一些第三方库可能不遵守此选项,特别是 libwrap 似乎只记录到 syslog。
-lp<progname>
Overrides the program name printed in error messages and used for
constructing environment variable names.
覆盖错误消息中打印的程序名称,并用于构建环境变量名称。
-lu
Extends the timestamp of error messages to microsecond resolution. Does not
work when logging to syslog.
将错误消息的时间戳扩展到微秒分辨率。在记录到 syslog 时不起作用。
-lm[<facility>]
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 <facility>, the syslog type can be
selected, default is "daemon".
混合日志模式。在启动期间,消息将打印到 stderr;当 socat 开始传输阶段循环或守护程序模式(即在打开所有流并开始数据传输之后,或者在具有 fork 选项的监听套接字中,在第一次接受调用之前),它将日志记录切换到 syslog。使用可选的 <facility>,可以选择 syslog 类型,默认为 "daemon"。
-lh
Adds hostname to log messages. Uses the value from environment variable
HOSTNAME or the value retrieved with uname() if HOSTNAME is not set.
将主机名添加到日志消息中。使用环境变量 HOSTNAME 的值或者如果未设置 HOSTNAME,则使用从 uname() 检索的值。
-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.
将传输的数据不仅写入其目标流,还写入 stderr。输出格式为文本,具有一些用于可读性的转换,并以 "> " 或 "< " 为前缀,指示流向。
-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
-v
.
将传输的数据不仅写入其目标流,还写入 stderr。输出格式为十六进制,以"> "或"< "开头,表示流向。可以与 -v 结合使用。
-r <file>
Dumps the raw (binary) data flowing from left to right address to the given
file. The file name may contain references to environment variables and
$$
(pid),
$PROGNAME
(see option option -lp),
$TIMESTAMP
(uses format %Y%m%dT%H%M%S), and
MICROS
(microseconds
of daytime). These references have to be protected from shell expansion of
course.
将从左到右地址流动的原始(二进制)数据转储到给定文件中。文件名可能包含对环境变量和 $$ (pid)、 $PROGNAME (参见选项 -lp)、 $TIMESTAMP (使用格式 %Y%m%dT%H%M%S)和 MICROS (白天微秒)的引用。当然,这些引用必须受到 shell 扩展的保护。
-R <file>
Dumps the raw (binary) data flowing from right to left address to the given
file. See option -r for customization of file name.
将从右到左地址流动的原始(二进制)数据转储到给定文件中。请参见选项 -r 以自定义文件名。
-b<size>
Sets the data transfer block <size> [size_t].
At most <size> bytes are transferred per step. Default is 8192 bytes.
设置数据传输块<size> [ size_t]。每步最多传输<size>字节。默认为 8192 字节。
-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.
默认情况下,socat 在发生错误时终止,以防止某些选项无法应用时进程继续运行。使用此选项,socat 对错误宽松处理并尝试继续。即使使用此选项,socat 也会在发生致命错误时退出,并在安全检查失败时中止连接尝试。
-S<signals-bitmap>
Changes the set of signals that are caught by socat just for printing an
log message. This catching is useful to get the information about the signal
into socats log, but prevents core dump or other standard actions. The
default set of these signals is SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT,
SIGBUS, SIGFPE, SIGSEGV, and SIGTERM; replace this set (0x89de on Linux)
with a bitmap (e.g., SIGFPE has value 8 and its bit is 0x0080). 更改 socat 捕获的信号集,仅用于打印日志消息。此捕获对于将信号信息记录到 socat 日志中很有用,但会阻止核心转储或其他标准操作。这些信号的默认集合是 SIGHUP、SIGINT、SIGQUIT、SIGILL、SIGABRT、SIGBUS、SIGFPE、SIGSEGV 和 SIGTERM;用位图(例如,SIGFPE 的值为 8,其位为 0x0080)替换此集合(在 Linux 上为 0x89de)。
Note: Signals SIGHUP, SIGINT, SIGQUIT, SIGUSR1, SIGPIPE, SIGALRM, SIGTERM, and
SIGCHLD may be handled specially anyway.
注意: 信号 SIGHUP、SIGINT、SIGQUIT、SIGUSR1、SIGPIPE、SIGALRM、SIGTERM 和 SIGCHLD 可能会被特殊处理。
-t<timeout>
When one channel has reached EOF, the write part of the other channel is shut
down. Then, socat waits <timeout> [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 interval the read part gives EOF, socat terminates without
awaiting the timeout.
当一个通道已经到达 EOF 时,另一个通道的写部分将被关闭。然后,socat 在终止之前等待 <timeout> [ timeval] 秒。默认为 0.5 秒。此超时仅适用于可以独立关闭写和读部分的地址。在超时间隔期间,如果读部分给出 EOF,则 socat 将在不等待超时的情况下终止。
-T<timeout>
Total inactivity timeout: when socat is already in the transfer loop and
nothing has happened for <timeout> [timeval] seconds
(no data arrived, no interrupt occurred...) then it terminates.
Useful with protocols like UDP that cannot transfer EOF.
总不活动超时: 当 socat 已经在传输循环中,并且在 <timeout> [ timeval] 秒内没有发生任何事情(没有数据到达,没有中断发生...)时,它将终止。对于像 UDP 这样无法传输 EOF 的协议非常有用。
-u
Uses unidirectional mode. The first address is only used for reading, and the
second address is only used for writing (example).
使用单向模式。第一个地址仅用于读取,第二个地址仅用于写入(示例)。
-U
Uses unidirectional mode in reverse direction. The first address is only
used for writing, and the second address is only used for reading.
在反向方向上使用单向模式。第一个地址仅用于写入,第二个地址仅用于读取。
-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.
在地址选项解析期间,不检查该选项在给定地址环境中是否被认为有用。如果要强制使用,例如将套接字选项应用于串行设备,请使用它。
-L<lockfile>
If lockfile exists, exits with error. If lockfile does not exist, creates it
and continues, unlinks lockfile on exit.
如果锁定文件存在,则以错误退出。如果锁定文件不存在,则创建它并继续,在退出时取消链接锁定文件。
-W<lockfile>
If lockfile exists, waits until it disappears. When lockfile does not exist,
creates it and continues, unlinks lockfile on exit.
如果锁定文件存在,则等待直到它消失。当锁定文件不存在时,创建它并继续,在退出时取消链接锁定文件。
-4
Use IP version 4 in case the addresses do not implicitly or explicitly
specify a version. Since version 1.8.0 the default is no preference.
如果地址没有明确或隐式指定版本,则使用 IP 版本 4。自版本 1.8.0 起,默认值为无偏好。
-6
Use IP version 6 in case the addresses do not implicitly or explicitly
specify a version.
如果地址没有明确或明确指定版本,请使用 IP 版本 6。
--statistics
-S
Logs transfer statistics (bytes and blocks counters for both directions)
before terminating socat. 在终止 socat 之前,传输日志传输统计信息(双向字节和块计数器)。
See also signal USR1. 另请参阅信号 USR1。
This feature is experimental and might change in future versions.
这个功能是实验性的,可能会在未来的版本中更改。
ADDRESS SPECIFICATIONS 地址规范
With the address command line arguments, the user gives socat instructions and
the necessary information for establishing the byte streams.
通过地址命令行参数,用户提供了 socat 指令和建立字节流所需的信息。
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.
关键字指定地址类型(例如,TCP4,OPEN,EXEC)。对于一些关键字,存在同义词(STDIO 的同义词为'-',TCP4 的同义词为 TCP)。关键字不区分大小写。对于一些特殊的地址类型,关键字可能被省略:以数字开头的地址规范被假定为 FD(原始文件描述符)地址;如果在第一个冒号或逗号之前发现'/',则假定为 GOPEN(通用文件打开)。
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).
必需的地址参数的数量和类型取决于地址类型。例如,TCP4 需要服务器规范(名称或地址)和端口规范(数字或服务名称)。
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).
每个地址可以附带零个或多个地址选项。它们以某种方式影响地址。选项由选项关键字或选项关键字和值组成,用 '=' 分隔。选项关键字不区分大小写。为了过滤与地址类型有用的选项,每个选项都是一个选项组的成员。对于每种地址类型,都允许一组选项组。只能使用属于这些地址组之一的选项(除了选项 -g)。
Address specifications following the above schema are also called single
address specifications.
Two single addresses can be combined with "!!" to form a 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.
遵循上述模式的地址规范也称为单地址规范。两个单地址可以用 "!!" 结合在一起,形成一个通道的双类型地址。在这里,第一个地址由 socat 用于读取数据,第二个地址用于写入数据。无法指定一个选项仅应用于两个单地址。
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.
通常,地址以读/写模式打开。当地址是双地址规范的一部分,或者使用选项 -u 或 -U 时,地址可能仅用于读取或写入。考虑到这一点对于某些地址类型很重要。
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 ""
从 socat 版本 1.5.0 及更高版本开始,词法分析尝试处理引号和括号的含义,并允许转义特殊字符。如果发现其中一个字符({ [ '),则会寻找相应的闭合字符 - ) } ] ' -;它们也可以嵌套。在这些结构内,socat 的特殊字符和字符串:,!! 不会被特殊处理。所有这些字符和字符串都可以用 \ 转义或在 "" 内部。
ADDRESS TYPES 地址类型
This section describes the available address types with their keywords,
parameters, and semantics.
本节描述了可用的地址类型及其关键字、参数和语义。
CREATE:<filename>
Opens <filename> with
creat()
and uses the file
descriptor for writing.
This is a write-only address because a file opened with
creat
cannot
be read from. See options -u and
-U, and dual addresses. 使用 creat() 打开 并使用文件描述符进行写入。这是一个只写地址,因为使用 creat 打开的文件无法读取。请参见选项 -u 和 -U,以及双地址。
Flags like O_LARGEFILE cannot be applied. If you need them use
OPEN with options
create,create. 无法应用类似 O_LARGEFILE 的标志。如果需要它们,请使用带有选项 create, create 的 OPEN。
<filename> must be a valid existing or not existing path.
If <filename> is a named pipe,
creat()
might block;
if <filename> refers to a socket, this is an error. 必须是有效的现有或不存在的路径。如果 是一个命名管道, creat() 可能会阻塞;如果 指向一个套接字,这将是一个错误。
Option groups: FD,REG,NAMED 选项组: FD, REG, NAMED
Useful options:
mode,
user,
group,
unlink-early,
unlink-late,
append 有用选项: 模式, 用户, 组, 提前取消链接, 晚取消链接, 追加
See also: OPEN, GOPEN 另请参阅: OPEN, GOPEN
Like DCCP-CONNECT, but only supports IPv4 protocol. 类似于 DCCP-CONNECT,但仅支持 IPv4 协议。
Option groups: FD,SOCKET,IP4,DCCP,CHILD,RETRY 选项组:FD,SOCKET,IP4,DCCP,CHILD,RETRY
DCCP6-CONNECT:<host>:<port> (DCCP6:<host>:<port>)
Like DCCP-CONNECT, but only supports IPv6 protocol. 类似于 DCCP-CONNECT,但仅支持 IPv6 协议。
Option groups: FD,SOCKET,IP6,DCCP,CHILD,RETRY 选项组:FD,SOCKET,IP6,DCCP,CHILD,RETRY
DCCP-LISTEN:<port> (DCCP-L:<port>)
Listens on <port> [DCCP service] and accepts an
DCCP connection. The IP version is 4 or the one specified with
address option pf, socat option
(-4, -6), or environment variable SOCAT_DEFAULT_LISTEN_IP.
Note that opening
this address usually blocks until a client connects. 在<端口>上监听[DCCP 服务]并接受 DCCP 连接。IP 版本为 4 或使用地址选项 pf、socat 选项(-4,-6)或环境变量 SOCAT_DEFAULT_LISTEN_IP 指定的版本。请注意,打开此地址通常会阻塞,直到客户端连接。
Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4,IP6,DCCP,RETRY 选项组: FD, SOCKET, LISTEN, CHILD, RANGE, IP4, IP6, DCCP, RETRY
Useful options:
fork,
bind,
range,
max-children,
backlog,
accept-timeout,
dccp-set-sid,
su,
reuseaddr,
retry 有用选项: fork, bind, range, max-children, backlog, accept-timeout, dccp-set-sid, su, reuseaddr, retry
See also:
DCCP4-LISTEN,
DCCP6-LISTEN,
TCP-LISTEN,
SCTP-LISTEN,
DCCP-CONNECT 另请参阅: DCCP4-LISTEN, DCCP6-LISTEN, TCP-LISTEN, SCTP-LISTEN, DCCP-CONNECT
Like DCCP-LISTEN, but only supports IPv6
protocol. 仅支持 IPv6 协议的类似 DCCP-LISTEN。
Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP6,DCCP,RETRY 选项组: FD, SOCKET, LISTEN, CHILD, RANGE, IP6, DCCP, RETRY
EXEC:<command-line>
Forks a sub process that establishes communication with its parent process
and invokes the specified program with
execvp()
.
<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
execvp()
semantics for finding the program via
$PATH
apply. After successful program start, socat writes data to stdin of the
process and reads from its stdout using a UNIX domain socket generated by
socketpair()
per default. (example) 分叉一个子进程,与其父进程建立通信,并使用 execvp() 调用指定的程序。 是一个简单的命令,参数之间用单个空格分隔。如果程序名称包含 '/', 则最后一个 '/' 后面的部分被视为 ARGV[0]。如果程序名称是相对路径,则使用 $PATH 应用程序查找的 execvp() 语义。成功启动程序后,socat 使用 socketpair() 默认生成的 UNIX 域套接字向进程的 stdin 写入数据,并从其 stdout 读取数据。 (示例)
Option groups: FD,SOCKET,EXEC,FORK,TERMIOS 选项组: FD, SOCKET, EXEC, FORK, TERMIOS
Useful options:
path,
fdin,
fdout,
chroot,
su,
su-d,
nofork,
socktype,
pty,
stderr,
ctty,
setsid,
pipes,
umask,
login,
sigint,
sigquit,
netns 有用的选项:路径,fdin,fdout,chroot,su,su-d,nofork,socktype,pty,stderr,ctty,setsid,pipes,umask,login,sigint,sigquit,netns
See also: SYSTEM,SHELL 另请参阅:系统,外壳
FD:<fdnum>
Uses the file descriptor <fdnum>. It must already exist as
valid UN*X file descriptor. 使用文件描述符<fdnum>。它必须已经存在为有效的 UNIX 文件描述符。
Option groups: FD (TERMIOS,REG,SOCKET) 选项组: FD ( TERMIOS, REG, SOCKET)
See also:
STDIO,
STDIN,
STDOUT,
STDERR 另请参阅: STDIO, STDIN, STDOUT, STDERR
GOPEN:<filename>
(Generic open) This address type tries to handle any file system entry
except directories usefully. <filename> may be a
relative or absolute path. If it already exists, its type is checked.
In case of a UNIX domain socket, socat connects; if connecting fails,
socat assumes a datagram socket and uses
sendto()
calls.
If the entry is not a socket, socat opens it applying the
O_APPEND
flag.
If it does not exist, it is opened with flag
O_CREAT
as a regular file (example). (通用打开) 此地址类型尝试有用地处理除目录之外的任何文件系统条目。 <文件名> 可以是相对路径或绝对路径。 如果它已经存在,则会检查其类型。 如果是 UNIX 域套接字,socat 将连接; 如果连接失败,socat 假定是数据报套接字并使用 sendto() 调用。 如果条目不是套接字,socat 将以 O_APPEND 标志打开它。 如果它不存在,则将以 O_CREAT 标志作为常规文件打开它(示例)。
Option groups: FD,REG,SOCKET,NAMED,OPEN 选项组: FD, REG, SOCKET, NAMED, OPEN
See also:
OPEN,
CREATE,
UNIX-CONNECT 另请参阅: OPEN, CREATE, UNIX-CONNECT
IP-SENDTO:<host>:<protocol>
Opens a raw IP socket. Depending on host specification or option pf, IP protocol version
4 or 6 is used. It uses <protocol> to send packets
to <host> [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. 打开原始 IP 套接字。根据主机规范或选项 pf,使用 IP 协议版本 4 或 6。它使用 <protocol> 发送数据包到 <host> [IP 地址] 并从主机接收数据包,忽略其他主机发送的数据包。协议 255 使用带有 IP 头部的原始套接字。
Option groups: FD,SOCKET,IP4,IP6 选项组: FD, SOCKET, IP4, IP6
Useful options:
pf,
ttl 有用的选项: pf, ttl
See also:
IP4-SENDTO,
IP6-SENDTO,
IP-RECVFROM,
IP-RECV,
UDP-SENDTO,
UNIX-SENDTO 另请参阅: IP4-SENDTO, IP6-SENDTO, IP-RECVFROM, IP-RECV, UDP-SENDTO, UNIX-SENDTO
INTERFACE:<interface>
Communicates with a network connected on an interface using raw packets
including link level data. <interface> is the name of
the network interface. Currently only available on Linux. 使用原始数据包与通过接口连接的网络进行通信,包括链路级数据。 <interface> 是网络接口的名称。目前仅在 Linux 上可用。
Option groups: FD,SOCKET 选项组:FD,SOCKET
Useful options:
pf,
type 有用选项:pf,类型
See also: ip-recv 参见:ip-recv
IP4-SENDTO:<host>:<protocol>
Like IP-SENDTO, but always uses IPv4. 类似于 IP-SENDTO,但始终使用 IPv4。
Option groups: FD,SOCKET,IP4 选项组:FD,SOCKET,IP4
IP6-SENDTO:<host>:<protocol>
Like IP-SENDTO, but always uses IPv6. 类似于 IP-SENDTO,但始终使用 IPv6。
Option groups: FD,SOCKET,IP6 选项组:FD,SOCKET,IP6
IP-DATAGRAM:<address>:<protocol>
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
RANGE or TCPWRAP
options. This address type can for example be used for implementing
symmetric or asymmetric broadcast or multicast communications. 将传出数据发送到指定地址,该地址可能是广播或组播地址。到达本地套接字的数据包将被检查,以查看它们的源地址是否与 RANGE 或 TCPWRAP 选项匹配。例如,此地址类型可用于实现对称或非对称广播或组播通信。
Option groups: FD, SOCKET,
IP4, IP6, RANGE 选项组: FD, SOCKET, IP4, IP6, RANGE
Useful options:
bind,
range,
tcpwrap,
broadcast,
ip-multicast-loop,
ip-multicast-ttl,
ip-multicast-if,
ip-add-membership,
ip-add-source-membership,
ipv6-join-group,
ipv6-join-source-group,
ttl,
tos,
pf 有用的选项: bind, range, tcpwrap, broadcast, ip-multicast-loop, ip-multicast-ttl, ip-multicast-if, ip-add-membership, ip-add-source-membership, ipv6-join-group, ipv6-join-source-group, ttl, tos, pf
See also:
IP4-DATAGRAM,
IP6-DATAGRAM,
IP-SENDTO,
IP-RECVFROM,
IP-RECV,
UDP-DATAGRAM 另请参阅: IP4-DATAGRAM, IP6-DATAGRAM, IP-SENDTO, IP-RECVFROM, IP-RECV, UDP-DATAGRAM
Like IP-DATAGRAM, but always uses IPv6. Please
note that IPv6 does not know broadcasts. 像 IP 数据报一样,但始终使用 IPv6。请注意,IPv6 不支持广播。
Option groups: FD,SOCKET,IP6,RANGE 选项组: FD, SOCKET, IP6, RANGE
IP-RECVFROM:<protocol>
Opens a raw IP socket of <protocol>. Depending on option pf, IP protocol 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. 打开一个原始 IP 套接字 <protocol>。根据选项 pf,将使用 IP 协议版本 4 或 6。它从未指定的对等方接收一个数据包,并可能向该对等方发送一个或多个应答数据包。此模式特别适用于 fork 选项,其中每个到达的数据包 - 来自任意对等方 - 都由自己的子进程处理。这允许类似于典型基于 UDP 的服务器(如 ntpd 或 named)的行为。
Please note that the reply packets might be fetched as incoming traffic when
sender and receiver IP address are identical because there is no port number
to distinguish the sockets. 请注意,当发送方和接收方的 IP 地址相同时,回复数据包可能被视为传入流量,因为没有端口号来区分套接字。
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. 这个地址与 IP-SENDTO 地址对等方很好地配合(见上文)。协议 255 使用原始套接字,其中 IP 头部是数据的一部分。
See the note about RECVFROM addresses. 请参阅关于 RECVFROM 地址的说明。
Option groups: FD,SOCKET,IP4,IP6,CHILD,RANGE 选项组:FD、SOCKET、IP4、IP6、CHILD、RANGE
Useful options:
pf,
fork,
range,
ttl,
broadcast 有用的选项:pf、fork、range、ttl、broadcast
See also:
IP4-RECVFROM,
IP6-RECVFROM,
IP-SENDTO,
IP-RECV,
UDP-RECVFROM,
UNIX-RECVFROM 另请参阅:IP4-RECVFROM、IP6-RECVFROM、IP-SENDTO、IP-RECV、UDP-RECVFROM、UNIX-RECVFROM
IP4-RECVFROM:<protocol>
Like IP-RECVFROM, but always uses IPv4. 类似于 IP-RECVFROM,但始终使用 IPv4。
Option groups: FD,SOCKET,IP4,CHILD,RANGE 选项组:FD,套接字,IP4,子级,范围
IP6-RECVFROM:<protocol>
Like IP-RECVFROM, but always uses IPv6. 类似于 IP-RECVFROM,但始终使用 IPv6。
Option groups: FD,SOCKET,IP6,CHILD,RANGE 选项组:FD,套接字,IP6,子级,范围
IP-RECV:<protocol>
Opens a raw IP socket of <protocol>. Depending on option pf, IP protocol version
4 or 6 is used. It receives packets from multiple unspecified peers and merges the data.
No replies are possible, this is a read-only address, see options -u and
-U, and dual addresses.
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. 打开一个 <protocol> 的原始 IP 套接字。根据选项 pf,将使用 IP 协议版本 4 或 6。它从多个未指定的对等方接收数据包并合并数据。不可能回复,这是一个只读地址,请参阅选项 -u 和 -U,以及双地址。例如,可以通过 socat IP-SENDTO 地址对对等方进行寻址。协议 255 使用带有 IP 头部的原始套接字。
Option groups: FD,SOCKET,IP4,IP6,RANGE 选项组:FD、SOCKET、IP4、IP6、RANGE
Useful options:
pf,
range 有用的选项:pf、range
See also:
IP4-RECV,
IP6-RECV,
IP-SENDTO,
IP-RECVFROM,
UDP-RECV,
UNIX-RECV 参见:IP4-RECV,IP6-RECV,IP-SENDTO,IP-RECVFROM,UDP-RECV,UNIX-RECV
IP4-RECV:<protocol>
Like IP-RECV, but always uses IPv4. 类似于 IP-RECV,但始终使用 IPv4。
Option groups: FD,SOCKET,IP4,RANGE 选项组:FD,SOCKET,IP4,RANGE
IP6-RECV:<protocol>
Like IP-RECV, but always uses IPv6. 类似于 IP-RECV,但始终使用 IPv6。
Option groups: FD,SOCKET,IP6,RANGE 选项组:FD,SOCKET,IP6,RANGE
OPEN:<filename>
Opens <filename> using the
open()
system call
(example).
This operation fails on UNIX domain sockets. 使用 open() 系统调用打开 (示例)。此操作在 UNIX 域套接字上失败。
Note: This address type is rarely useful in bidirectional mode. 注意:此地址类型在双向模式下很少有用。
Option groups: FD,REG,NAMED,OPEN 选项组:FD、REG、NAMED、OPEN
Useful options:
creat,
excl,
noatime,
nofollow,
append,
rdonly,
wronly,
lock,
readbytes,
ignoreeof 有用选项:creat、excl、noatime、nofollow、append、rdonly、wronly、lock、readbytes、ignoreeof
See also:
CREATE,
GOPEN,
UNIX-CONNECT 另请参阅:CREATE,GOPEN,UNIX-CONNECT
OPENSSL:<host>:<port>
Tries to establish a SSL connection to <port> [TCP
service] on
<host> [IP address] using TCP/IP version 4 or 6
depending on address specification, name resolution, or option
pf. 尝试使用 TCP/IP 版本 4 或 6(取决于地址规范、名称解析或选项 pf)在 <host> [IP 地址] 上的 <port> [TCP 服务] 建立 SSL 连接。
NOTE: Up to version 1.7.2.4
the server certificate was only checked for validity against the system
certificate store or cafile or
capath,
but not for match with the server's name or its IP address.
Since version 1.7.3.0 socat checks the peer certificate for match with the
<host> parameter or the value of the
openssl-commonname option.
Socat tries to match it against the certificates subject commonName,
and the certificates extension subjectAltName DNS names. Wildcards in the
certificate are supported. 注意:在版本 1.7.2.4 之前,服务器证书仅针对系统证书存储区、cafile 或 capath 的有效性进行检查,但不检查与服务器名称或其 IP 地址的匹配。自版本 1.7.3.0 起,socat 会检查对等证书是否与 <host> 参数或 openssl-commonname 选项的值匹配。Socat 会尝试将其与证书的主题 commonName 和证书扩展主题 subjectAltName DNS 名称进行匹配。证书中的通配符受支持。
Option groups: FD,SOCKET,IP4,IP6,TCP,OPENSSL,RETRY 选项组: FD, SOCKET, IP4, IP6, TCP, OPENSSL, RETRY
Useful options:
min-proto-version,
cipher,
verify,
commonname,
cafile,
capath,
certificate,
key,
compress,
bind,
pf,
connect-timeout,
sourceport,
retry 有用选项: min-proto-version, cipher, verify, commonname, cafile, capath, certificate, key, compress, bind, pf, connect-timeout, sourceport, retry
See also:
OPENSSL-LISTEN,
TCP 另请参阅: OPENSSL-LISTEN, TCP
OPENSSL-LISTEN:<port>
Listens on tcp <port> [TCP service].
The IP version is 4 or the one specified with
pf. When a
connection is accepted, this address behaves as SSL server. 在 TCP <端口> [TCP 服务] 上监听。IP 版本为 4 或使用 pf 指定的版本。当连接被接受时,此地址将作为 SSL 服务器。
Note: You probably want to use the certificate option with this address. 注意:您可能希望在此地址上使用证书选项。
NOTE: 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! 注意:客户端证书仅针对 cafile 或 capath 进行有效性检查,但不检查与客户端名称或 IP 地址的匹配!
Option groups: FD,SOCKET,IP4,IP6,TCP,LISTEN,OPENSSL,CHILD,RANGE,RETRY 选项组: FD, SOCKET, IP4, IP6, TCP, LISTEN, OPENSSL, CHILD, RANGE, RETRY
Useful options:
pf,
min-proto-version,
cipher,
verify,
commonname,
cafile,
capath,
certificate,
key,
compress,
fork,
bind,
range,
tcpwrap,
su,
reuseaddr,
retry 有用选项: pf, min-proto-version, cipher, verify, commonname, cafile, capath, certificate, key, compress, fork, bind, range, tcpwrap, su, reuseaddr, retry
See also:
OPENSSL,
TCP-LISTEN 另请参阅: OPENSSL, TCP-LISTEN
OPENSSL-DTLS-CLIENT:<host>:<port>
Tries to establish a DTLS connection to <port> [UDP
service] on
<host> [IP address] using UDP/IP version 4 or 6
depending on address specification, name resolution, or option
pf. 尝试使用 UDP/IP 版本 4 或 6,根据地址规范、名称解析或选项 pf,在 <host> [IP 地址] 上的 <port> [UDP 服务] 建立 DTLS 连接。 Socat checks the peer certificates subjectAltName or commonName against the addresses
option openssl-commonname or the host name.
Wildcards in the certificate are supported. Socat 检查对等证书的 subjectAltName 或 commonName 是否与地址选项 openssl-commonname 或主机名匹配。证书中的通配符受支持。
Use socat option -b to make datagrams small enough to fit with overhead
on the network. Use option -T to prevent indefinite hanging when peer went down quietly. 使用 socat 选项 -b 使数据报文足够小,以适应网络开销。使用选项 -T 防止对等方悄悄关闭时出现无限挂起。
Option groups: FD,SOCKET,IP4,IP6,OPENSSL,RETRY 选项组: FD, SOCKET, IP4, IP6, OPENSSL, RETRY
Useful options:
min-proto-version,
cipher,
verify,
commonname,
cafile,
capath,
certificate,
key,
compress,
bind,
pf,
sourceport,
retry,
rcvtimeo 有用选项: min-proto-version, cipher, verify, commonname, cafile, capath, certificate, key, compress, bind, pf, sourceport, retry, rcvtimeo
See also:
OPENSSL-DTLS-SERVER,
OPENSSL-CONNECT,
UDP-CONNECT 另请参阅: OPENSSL-DTLS-SERVER, OPENSSL-CONNECT, UDP-CONNECT
OPENSSL-DTLS-SERVER:<port>
Listens on UDP <port> [UDP service].
The IP version is 4 or the one specified with
pf. When a
connection is accepted, this address behaves as DTLS server. 在 UDP <port> [ UDP 服务] 上进行监听。IP 版本为 4 或使用 pf 指定的版本。当连接被接受时,此地址将作为 DTLS 服务器。
Note: You probably want to use the certificate option with this address. 注意: 您可能希望在此地址上使用证书选项。
NOTE: 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!
Use socat option -b to make datagrams small enough to fit with overhead on the network.
Use option -T to prevent indefinite hanging when peer went down quietly. 注意: 客户端证书仅针对 cafile 或 capath 进行有效性检查,但不检查与客户端名称或其 IP 地址的匹配!使用 socat 选项 -b 使数据报文足够小,以适应网络上的开销。使用选项 -T 防止对等方悄悄关闭时导致无限挂起。
Option groups: FD,SOCKET,IP4,IP6,LISTEN,OPENSSL,CHILD,RANGE,RETRY 选项组: FD, SOCKET, IP4, IP6, LISTEN, OPENSSL, CHILD, RANGE, RETRY
Useful options:
pf,
min-proto-version,
cipher,
verify,
commonname,
cafile,
capath,
certificate,
key,
compress,
fork,
bind,
range,
tcpwrap,
su,
reuseaddr,
retry 有用选项: pf, min-proto-version, cipher, verify, commonname, cafile, capath, certificate, key, compress, fork, bind, range, tcpwrap, su, reuseaddr, retry rcvtimeo
See also:
OPENSSL-DTLS-CLIENT,
OPENSSL-LISTEN,
UDP-LISTEN 查看也: OPENSSL-DTLS-CLIENT, OPENSSL-LISTEN, UDP-LISTEN
PIPE:<filename>
If <filename> already exists, it is opened.
If it 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 如果<filename>已经存在,则打开它。如果不存在,则创建并打开一个命名管道。从 socat 版本 1.4.3 开始,当地址关闭时,命名管道将被删除(但请参阅选项 unlink-close)
Note: When a pipe is used for both reading and writing, it works
as echo service. 注意: 当管道用于读写时,它将作为回显服务。
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.,
-b 2048 注意: 当管道用于读写时,并且 socat 尝试写入的字节数超过管道可以缓冲的字节数(Linux 2.4: 2048 字节),socat 可能会阻塞。考虑使用 socat 选项,例如, -b 2048
Option groups: FD,NAMED,OPEN 选项组: FD, NAMED, OPEN
Useful options:
rdonly,
nonblock,
group,
user,
mode,
unlink-early 有用的选项: rdonly, nonblock, group, user, mode, unlink-early
See also: unnamed pipe 参见:无名管道
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. 创建一个无名管道,并将其用于读取和写入。它的工作原理类似于回声,因为写入管道的所有内容立即显示为读取数据。
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
-b 2048 注意:当 socat 尝试写入的字节数超过管道可以排队的字节数(Linux 2.4:2048 字节)时,socat 可能会阻塞。考虑,例如,使用选项 -b 2048
Option groups: FD 选项组: FD
See also: named pipe, SOCKETPAIR 另请参阅: 命名管道,SOCKETPAIR
SOCKETPAIR
Creates a socketpair and uses it for reading and writing. It works as an
echo, because everything written to it appeares immediately as read
data. The default socket type is datagram, so it keeps packet boundaries.
创建一个 socketpair 并将其用于读取和写入。它的工作方式类似于回声,因为写入的所有内容立即显示为读取数据。默认的套接字类型是数据报,因此它保留数据包边界。
Option groups: FD 选项组: FD
Useful options:
socktype 有用的选项: socktype
See also: unnamed pipe 另请参阅: 无名管道
POSIXMQ-READ:/<mqueue>
Opens the specified POSIX message queue and reads messages (packets). It
keeps the boundaries. 打开指定的 POSIX 消息队列并读取消息(数据包)。它保持边界。
This is a read-only address, see options -u and
-U and dual addresses. 这是一个只读地址,请参阅选项 -u 和 -U 以及双地址。 Socat provides this address type only on Linux because POSIX MQ is based
on UNIX filedescriptors there. Socat 仅在 Linux 上提供此地址类型,因为 POSIX MQ 在那里基于 UNIX 文件描述符。
This feature is new in version 1.8.0.0 and might change in the future,
therefore it is experimental. 此功能是在版本 1.8.0.0 中新增的,可能会在未来发生变化,因此它是实验性的。
Useful options:
posixmq-priority,
unlink-early,
unlink-close 有用的选项:posixmq-priority,unlink-early,unlink-close
POSIXMQ-RECEIVE:/<mqueue>
POSIXMQ-RECV:/<mqueue>
Opens the specified POSIX message queue and reads one message (packet). 打开指定的 POSIX 消息队列并读取一个消息(数据包)。
This is a read-only address. See POSIXMQ-READ
for more info. 这是一个只读地址。查看 POSIXMQ-READ 以获取更多信息。
Example: POSIX MQ recv with fork 示例:带有 fork 的 POSIX MQ 接收
This feature is experimental. 此功能是实验性的。
Useful options:
posixmq-priority,
fork,
max-children,
unlink-early,
unlink-close 有用的选项:posixmq-priority,fork,max-children,unlink-early,unlink-close
POSIXMQ-SEND:/<mqueue>
Opens the specified POSIX message queue and writes messages (packets). 打开指定的 POSIX 消息队列并写入消息(数据包)。
This is a write-only address. See POSIXMQ-READ
for more info. 这是一个只写地址。有关更多信息,请参阅 POSIXMQ-READ。
(Example) ( 示例)
This feature is experimental. 此功能是实验性的。
Useful options:
posixmq-priority,
fork,
max-children,
unlink-early,
unlink-close 有用的选项:posixmq-priority,fork,max-children,unlink-early,unlink-close
POSIXMQ-BIDIRECTIONAL:/mqueue
Opens the specified POSIX message queue and writes and reads messages
(packet). This is probably rarely useful but has been implemented for
functional completeness.
打开指定的 POSIX 消息队列,并写入和读取消息(数据包)。这可能很少有用,但已实现以实现功能完整性。
PROXY:<proxy>:<hostname>:<port>
Connects to an HTTP proxy server on port 8080 using TCP/IP version 4 or 6
depending on address specification, name resolution, or option
pf, 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 (example).
Note that the traffic need not be HTTP but can be an arbitrary protocol. 使用 TCP/IP 版本 4 或 6(取决于地址规范、名称解析或选项 pf)连接到端口 8080 上的 HTTP 代理服务器,并发送主机名:端口的 CONNECT 请求。如果代理授予访问权限并成功连接到目标,socat 和目标之间的数据传输可以开始(示例)。请注意,流量不一定是 HTTP,而可以是任意协议。
Option groups: FD,SOCKET,IP4,IP6,TCP,HTTP,RETRY 选项组:FD、SOCKET、IP4、IP6、TCP、HTTP、RETRY
Useful options:
proxyport,
ignorecr,
proxyauth,
resolve,
crnl,
bind,
connect-timeout,
mss,
sourceport,
retry 有用的选项:代理端口,忽略回车,代理认证,解析,回车换行,绑定,连接超时,最大分段大小,源端口,重试
See also: SOCKS, TCP 另请参阅:SOCKS,TCP
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.
(example). If
both the ptmx and the openpty mechanisms are available, ptmx is used
(POSIX). 生成伪终端(pty)并使用其主端。另一个进程可以打开 pty 的从端,像使用串行线路或终端一样(示例)。如果 ptmx 和 openpty 机制都可用,则使用 ptmx(POSIX)。
Option groups: FD,NAMED,PTY,TERMIOS 选项组: FD, NAMED, PTY, TERMIOS
Useful options:
link,
openpty,
wait-slave,
mode,
user,
group 有用的选项: link, openpty, wait-slave, mode, user, group
See also:
UNIX-LISTEN,
PIPE,
EXEC, SYSTEM, SHELL 另请参阅: UNIX-LISTEN, PIPE, EXEC, SYSTEM, SHELL
READLINE
Uses GNU readline and history on stdio to allow editing and reusing input
lines (example). This requires the GNU readline and
history libraries. Note that stdio should be a (pseudo) terminal device,
otherwise readline does not seem to work. 使用 GNU readline 和 history 在 stdio 上允许编辑和重用输入行(示例)。这需要 GNU readline 和 history 库。请注意,stdio 应该是一个(伪)终端设备,否则 readline 似乎无法工作。
Option groups: FD,READLINE,TERMIOS 选项组:FD,READLINE,TERMIOS
Useful options:
history,
noecho 有用的选项:history,noecho
See also:
STDIO 查看也: STDIO
Creates a stream socket using the first and second given socket parameters
and SOCK_STREAM (see man socket(2)) and connects to the remote-address.
The two socket parameters have to be specified by int
numbers. Consult your OS documentation and include files to find the
appropriate values. The remote-address must be the data
representation of a sockaddr structure without sa_family and (BSD) sa_len
components. 使用第一个和第二个给定的套接字参数以及 SOCK_STREAM (参见 man socket(2))创建一个流套接字,并连接到远程地址。这两个套接字参数必须由 int 数字指定。请查阅您的操作系统文档和包含文件,以找到适当的值。远程地址必须是一个不带 sa_family 和(BSD)sa_len 组件的 sockaddr 结构的数据表示形式。
Please note that you can - beyond the options of the specified groups - also
use options of higher level protocols when you apply socat option
-g. 请注意,当您应用 socat 选项 -g 时,除了指定组的选项之外,您还可以使用更高级别协议的选项。
Option groups: FD,SOCKET,CHILD,RETRY 选项组:FD,SOCKET,CHILD,RETRY
Useful options:
bind,
setsockopt,
有用的选项:bind,setsockopt
See also:
TCP,
UDP-CONNECT,
UNIX-CONNECT,
SOCKET-LISTEN,
SOCKET-SENDTO 参见:TCP,UDP-CONNECT,UNIX-CONNECT,SOCKET-LISTEN,SOCKET-SENDTO
Creates a datagram socket using the first three given socket parameters (see
man socket(2)) and sends outgoing data to the remote-address. The three
socket parameters have to be specified by int
numbers. Consult your OS documentation and include files to find the
appropriate values. The remote-address must be the data
representation of a sockaddr structure without sa_family and (BSD) sa_len
components. 使用前三个给定的套接字参数(参见 man socket(2))创建数据报套接字,并将传出数据发送到远程地址。必须使用 int 数字指定三个套接字参数。请查阅您的操作系统文档和包含文件,以找到适当的值。远程地址必须是不带 sa_family 和(BSD)sa_len 组件的 sockaddr 结构的数据表示。
Please note that you can - beyond the options of the specified groups - also
use options of higher level protocols when you apply socat option
-g. 请注意,当您应用 socat 选项 -g 时,除了指定组的选项外,还可以使用更高级别协议的选项。
Option groups: FD,SOCKET,RANGE 选项组: FD, SOCKET, RANGE
Useful options:
bind,
range,
setsockopt,
有用的选项: bind, range, setsockopt
See also:
UDP-DATAGRAM,
IP-DATAGRAM,
SOCKET-SENDTO,
SOCKET-RECV,
SOCKET-RECVFROM 另请参阅: UDP-DATAGRAM, IP-DATAGRAM, SOCKET-SENDTO, SOCKET-RECV, SOCKET-RECVFROM
SOCKET-LISTEN:<domain>:<protocol>:<local-address>
Creates a stream socket using the first and second given socket parameters
and SOCK_STREAM (see man socket(2)) and waits for incoming connections
on local-address. The two socket parameters have to be specified by
int numbers. Consult your OS documentation and include files
to find the appropriate values. The local-address must be the
data representation of a sockaddr structure without
sa_family and (BSD) sa_len components. 使用第一个和第二个给定的套接字参数以及 SOCK_STREAM (参见 man socket(2))创建流套接字,并在本地地址上等待传入连接。这两个套接字参数必须由整数数字指定。请查阅您的操作系统文档和包含文件以找到适当的值。本地地址必须是不带 sa_family 和(BSD)sa_len 组件的 sockaddr 结构的数据表示。
Please note that you can - beyond the options of the specified groups - also
use options of higher level protocols when you apply socat option
-g. 请注意,当您应用 socat 选项 -g 时,除了指定组的选项之外,还可以使用更高级别协议的选项。
Option groups: FD,SOCKET,LISTEN,RANGE,CHILD,RETRY 选项组:FD、SOCKET、LISTEN、RANGE、CHILD、RETRY
Useful options:
setsockopt,
setsockopt-listen,
有用的选项:setsockopt、setsockopt-listen
See also:
TCP,
UDP-CONNECT,
UNIX-CONNECT,
SOCKET-LISTEN,
SOCKET-SENDTO,
SOCKET-SENDTO 另请参阅:TCP、UDP-CONNECT、UNIX-CONNECT、SOCKET-LISTEN、SOCKET-SENDTO、SOCKET-SENDTO
Creates a socket using the three given socket parameters (see man socket(2))
and binds it to <local-address>. Receives arriving data. The three
parameters have to be specified by int numbers. Consult your
OS documentation and include files to find the appropriate values. The
local-address must be the data representation of a sockaddr
structure without sa_family and (BSD) sa_len components. 使用给定的三个套接字参数(参见 man socket(2))创建套接字,并将其绑定到<local-address>。接收到达的数据。这三个参数必须由 int 数字指定。请查阅您的操作系统文档和包含文件,以找到适当的值。local-address 必须是 sockaddr 结构的数据表示形式,不包含 sa_family 和(BSD)sa_len 组件。
Option groups: FD,SOCKET,RANGE 选项组: FD, SOCKET, RANGE
Useful options:
range,
setsockopt,
setsockopt-listen 有用选项: 范围, setsockopt, setsockopt-listen
See also:
UDP-RECV,
IP-RECV,
UNIX-RECV,
SOCKET-DATAGRAM,
SOCKET-SENDTO,
SOCKET-RECVFROM 另请参阅: UDP-RECV, IP-RECV, UNIX-RECV, SOCKET-DATAGRAM, SOCKET-SENDTO, SOCKET-RECVFROM
Creates a socket using the three given socket parameters (see man socket(2))
and binds it to <local-address>. Receives arriving data and sends replies
back to the sender. The first three parameters have to be specified as
int numbers. Consult your OS documentation and include files
to find the appropriate values. The local-address must be the
data representation of a sockaddr structure without
sa_family and (BSD) sa_len components. 使用三个给定的套接字参数(参见 man socket(2))创建套接字并将其绑定到<本地地址>。接收到达的数据并将回复发送回发送者。前三个参数必须指定为 int 数字。请查阅您的操作系统文档和包含文件,以找到适当的值。本地地址必须是不带 sa_family 和(BSD)sa_len 组件的 sockaddr 结构的数据表示。
See the note about RECVFROM addresses. 查看有关 RECVFROM 地址的说明。
Option groups: FD,SOCKET,CHILD,RANGE 选项组:FD、SOCKET、CHILD、RANGE
Useful options:
fork,
range,
setsockopt,
setsockopt-listen 有用的选项:fork、range、setsockopt、setsockopt-listen
See also:
UDP-RECVFROM,
IP-RECVFROM,
UNIX-RECVFROM,
SOCKET-DATAGRAM,
SOCKET-SENDTO,
SOCKET-RECV 另请参阅:UDP-RECVFROM、IP-RECVFROM、UNIX-RECVFROM、SOCKET-DATAGRAM、SOCKET-SENDTO、SOCKET-RECV
Creates a socket using the three given socket parameters (see man
socket(2)). Sends outgoing data to the given address and receives replies.
The three parameters have to be specified as int
numbers. Consult your OS documentation and include files to find the
appropriate values. The remote-address must be the data
representation of a sockaddr structure without sa_family and (BSD) sa_len
components. 使用三个给定的套接字参数创建套接字(参见 man socket(2))。将传出数据发送到给定地址并接收回复。必须将三个参数指定为 int 数字。请查阅您的操作系统文档和包含文件,以找到适当的值。远程地址必须是不带 sa_family 和(BSD)sa_len 组件的 sockaddr 结构的数据表示形式。
Option groups: FD,SOCKET 选项组: FD, SOCKET
Useful options:
bind,
setsockopt,
setsockopt-listen 有用的选项: bind, setsockopt, setsockopt-listen
See also:
UDP-SENDTO,
IP-SENDTO,
UNIX-SENDTO,
SOCKET-DATAGRAM,
SOCKET-RECVSOCKET-RECVFROM 另请参阅: UDP-SENDTO, IP-SENDTO, UNIX-SENDTO, SOCKET-DATAGRAM, SOCKET-RECV SOCKET-RECVFROM
ACCEPT-FD:<fdnum>
Expects a listening socket in <fdnum> and accepts one or (with option
fork) more connections. This address type is useful under
systemd control with "inetd mode". 期望在<fdnum>中有一个监听套接字,并接受一个或多个连接。此地址类型在 systemd 控制下的“inetd 模式”下很有用。
Example: (example) 示例:(示例)
Option groups: FD, SOCKET, TCP, CHILD, RETRY 选项组:FD、SOCKET、TCP、CHILD、RETRY
Useful options:
fork,
range,
sourceport,
lowport,
tcpwrap 有用的选项:fork、range、sourceport、lowport、tcpwrap
SOCKS4:<socks-server>:<host>:<port>
Connects via <socks-server> [IP address]
to <host> [IPv4 address]
on <port> [TCP service],
using socks version 4 protocol over IP version 4 or 6 depending on address specification, name resolution, or option
pf (example). 通过 <socks-server> [IP 地址] 连接到 <host> [IPv4 地址] 的 <port> [TCP 服务],使用 socks 版本 4 协议,根据地址规范、名称解析或选项 pf(示例)在 IP 版本 4 或 6 上进行
Option groups: FD,SOCKET,IP4,IP6,TCP,SOCKS4,RETRY 选项组:FD、SOCKET、IP4、IP6、TCP、SOCKS4、RETRY
Useful options:
socksuser,
socksport,
sourceport,
pf,
retry 有用的选项:socksuser、socksport、sourceport、pf、retry
See also:
SOCKS5,
SOCKS4A,
PROXY,
TCP 另请参阅:SOCKS5、SOCKS4A、PROXY、TCP
SOCKS4A:<socks-server>:<host>:<port>
like SOCKS4, but uses socks protocol version 4a, thus
leaving host name resolution to the socks server. 类似于 SOCKS4,但使用 socks 协议版本 4a,因此将主机名解析留给 socks 服务器。
Option groups: FD,SOCKET,IP4,IP6,TCP,SOCKS4,RETRY 选项组: FD, SOCKET, IP4, IP6, TCP, SOCKS4, RETRY
Connects to <socks-server> [IP address]
using socks version 5 protocol over TCP
and makes it listen for incoming connections on <listen-port> [TCP service], binding to <-listen-host> [IPv4 address]
Currently not authentication mechanism is provided. This address type is experimental.
Option groups: FD, SOCKET, IP4, IP6, TCP, CHILD, RETRY 使用 SOCKS 版本 5 协议通过 TCP 连接到 <socks-server> [IP 地址],并使其监听 <listen-port> [TCP 服务] 上的传入连接,绑定到 <-listen-host> [IPv4 地址]。目前没有提供身份验证机制。此地址类型是实验性的。选项组:FD、SOCKET、IP4、IP6、TCP、CHILD、RETRY
Useful options:
sourceport,
pf,
retry 有用的选项:sourceport、pf、retry
See also:
SOCKS5-CONNECT,
另请参阅:SOCKS5-CONNECT
STDERR
Uses file descriptor 2. 使用文件描述符 2。
This is a write-only address, see options -u and
-U, and dual addresses. 这是一个只写地址,请参阅选项 -u 和 -U,以及双地址。
Option groups: FD (TERMIOS,REG,SOCKET) 选项组:FD(TERMIOS,REG,SOCKET)
See also: FD 另请参阅:FD
STDIN
Uses file descriptor 0. 使用文件描述符 0。
This is a read-only address, see options -u and
-U, and dual addresses. 这是一个只读地址,请参阅选项 -u 和 -U,以及双地址。
Option groups: FD (TERMIOS,REG,SOCKET) 选项组: FD (TERMIOS, REG, SOCKET)
Useful options:
readbytes 有用选项: readbytes
See also: FD 另请参阅: FD
STDIO
Uses file descriptor 0 for reading, and 1 for writing. 使用文件描述符 0 进行读取,1 进行写入。
Option groups: FD (TERMIOS,REG,SOCKET) 选项组:FD(TERMIOS,REG,SOCKET)
Useful options:
readbytes 有用的选项:readbytes
See also: FD 参见:FD
STDOUT
Uses file descriptor 1. 使用文件描述符 1。
This is a write-only address, see options -u and
-U, and dual addresses. 这是一个只写地址,请参阅选项 -u 和 -U,以及双地址。
Option groups: FD (TERMIOS,REG,SOCKET) 选项组: FD (TERMIOS, REG, SOCKET)
See also: FD 另请参阅: FD
SHELL:<shell-command>
Forks a sub process that establishes communication with its parent process
and invokes the specified program with the configured shell ($SHELL).
Note that <shell-command> [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. 分叉一个子进程,与其父进程建立通信,并使用配置的 shell ($SHELL) 调用指定的程序。请注意,<shell-command> [ string] 不能包含 ',' 或 "!!",并且 shell 元字符可能需要保护。成功启动程序后,socat 将数据写入进程的 stdin 并从其 stdout 读取。
Option groups: FD,SOCKET,EXEC,FORK,TERMIOS 选项组: FD, SOCKET, EXEC, FORK, TERMIOS
Useful options:
path,
fdin,
fdout,
chroot,
su,
su-d,
nofork,
socktype,
pty,
stderr,
ctty,
setsid,
pipes,
umask,
sigint,
sigquit 有用选项: 路径, fdin, fdout, chroot, su, su-d, nofork, socktype, pty, stderr, ctty, setsid, pipes, umask, sigint, sigquit
See also: EXEC, SYSTEM 另请参阅: EXEC, SYSTEM
SYSTEM:<shell-command>
Forks a sub process that establishes communication with its parent process
and invokes the specified program with
system()
. Please note that
<shell-command> [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. 创建一个与其父进程建立通信并使用 system() 调用指定程序的子进程。请注意, [字符串] 不能包含','或"!!",并且 shell 元字符可能需要受保护。成功启动程序后,socat 将数据写入进程的 stdin 并从其 stdout 读取。
Option groups: FD,SOCKET,EXEC,FORK,TERMIOS 选项组:FD,SOCKET,EXEC,FORK,TERMIOS
Useful options:
path,
fdin,
fdout,
chroot,
su,
su-d,
nofork,
socktype,
pty,
stderr,
ctty,
setsid,
pipes,
umask,
sigint,
sigquit,
netns 有用的选项:路径,fdin,fdout,chroot,su,su-d,nofork,socktype,pty,stderr,ctty,setsid,pipes,umask,sigint,sigquit,netns
See also: EXEC, SHELL 参见:EXEC,SHELL
Like TCP-LISTEN, but only supports IPv6
protocol. 类似于 TCP-LISTEN,但仅支持 IPv6 协议。
Additional useful option:
ipv6only 附加有用选项:ipv6only
Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP6,TCP,RETRY 选项组:FD,SOCKET,LISTEN,CHILD,RANGE,IP6,TCP,RETRY
TUN[:<if-addr>/<bits>]
Creates a Linux TUN/TAP device and optionally assignes it the address and
netmask given by the parameters. The resulting network interface is almost
ready for use by other processes; socat serves its "wire side". This address
requires read and write access to the tunnel cloning device, usually
/dev/net/tun
, as well as permission to set some ioctl()s.
Option iff-up is required to immediately activate the interface! 创建一个 Linux TUN/TAP 设备,并可选择为其分配由参数给定的地址和子网掩码。生成的网络接口几乎可以被其他进程使用;socat 服务于其“线路端”。该地址需要对隧道克隆设备(通常为 /dev/net/tun )具有读写访问权限,以及设置某些 ioctl()s 的权限。选项 iff-up 用于立即激活接口!
Note: If you intend to transfer packets between two Socat "wire sides" you
need a protocol that keeps packet boundaries, e.g.UDP; TCP might work with
option nodelay. 注意:如果您打算在两个 Socat “线路端”之间传输数据包,您需要一个保持数据包边界的协议,例如 UDP;TCP 可能需要使用选项 nodelay。
Option groups: FD,NAMED,OPEN,TUN 选项组:FD、NAMED、OPEN、TUN
Useful options:
iff-up,
tun-device,
tun-name,
tun-type,
iff-no-pi,
netns 有用的选项:iff-up、tun-device、tun-name、tun-type、iff-no-pi、netns
See also:
ip-recv 另请参阅:ip-recv
UDP:<host>:<port>
Connects to <port> [UDP service] on
<host> [IP address] using UDP/IP version 4 or 6
depending on address specification, name resolution, or option
pf. 使用基于地址规范、名称解析或选项 pf 的 UDP/IP 版本 4 或 6 连接到 <host> [IP 地址] 上的 <port> [UDP 服务]。
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. 请注意,由于 UDP 协议的特性,不会建立真正的连接;必须发送数据以进行“连接”到服务器,并且无法传输文件结束条件。
Option groups: FD,SOCKET,IP4,IP6 选项组:FD,SOCKET,IP4,IP6
Useful options:
ttl,
tos,
bind,
sourceport,
pf 有用的选项:ttl,tos,bind,sourceport,pf
See also:
UDP4,
UDP6,
UDP-LISTEN,
TCP,
IP 参见:UDP4,UDP6,UDP-LISTEN,TCP,IP
UDP4:<host>:<port>
Like UDP, but only supports IPv4 protocol. 类似于 UDP,但仅支持 IPv4 协议。
Option groups: FD,SOCKET,IP4 选项组:FD,SOCKET,IP4
UDP6:<host>:<port>
Like UDP, but only supports IPv6 protocol. 像 UDP 一样,但仅支持 IPv6 协议。
Option groups: FD,SOCKET,IP6 选项组:FD、SOCKET、IP6
UDP-DATAGRAM:<address>:<port>
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 only when option sourceport is used (this is a change with Socat version 1.7.4.0) and if their source addresses match
RANGE or TCPWRAP
options. This address type can for example be used for implementing
symmetric or asymmetric broadcast or multicast communications. 将传出数据发送到指定地址,该地址可能是广播或组播地址。当使用选项 sourceport 时,本地套接字上到达的数据包仅在其源地址匹配 RANGE 或 TCPWRAP 选项时才检查正确的远程端口(这是 Socat 版本 1.7.4.0 的更改)。例如,此地址类型可用于实现对称或非对称广播或组播通信。
Option groups: FD,SOCKET,IP4,IP6,RANGE 选项组: FD, SOCKET, IP4, IP6, RANGE
Useful options:
bind,
range,
tcpwrap,
broadcast,
ip-multicast-loop,
ip-multicast-ttl,
ip-multicast-if,
ip-add-membership,
ip-add-source-membership,
ipv6-join-group,
ipv6-join-source-group,
ttl,
tos,
sourceport,
pf 有用的选项: bind, range, tcpwrap, broadcast, ip-multicast-loop, ip-multicast-ttl, ip-multicast-if, ip-add-membership, ip-add-source-membership, ipv6-join-group, ipv6-join-source-group, ttl, tos, sourceport, pf
See also:
UDP4-DATAGRAM,
UDP6-DATAGRAM,
UDP-SENDTO,
UDP-RECVFROM,
UDP-RECV,
UDP-CONNECT,
UDP-LISTEN,
IP-DATAGRAM 另请参阅: UDP4-DATAGRAM, UDP6-DATAGRAM, UDP-SENDTO, UDP-RECVFROM, UDP-RECV, UDP-CONNECT, UDP-LISTEN, IP-DATAGRAM
Like UDP-DATAGRAM, but only supports IPv6
protocol. 像 UDP 数据报一样,但仅支持 IPv6 协议。
Option groups: FD,SOCKET,IP6,RANGE 选项组: FD, SOCKET, IP6, RANGE
UDP-LISTEN:<port>
Waits for a UDP/IP packet arriving on <port>
[UDP service] and `connects' back to sender.
The accepted IP version is 4 or the one specified with option
pf.
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. 等待 UDP/IP 数据包到达 <端口> [UDP 服务],并向发送方“连接”回去。接受的 IP 版本为 4 或使用选项 pf 指定的版本。请注意,由于 UDP 协议的特性,不会建立真正的连接;数据必须先从对等方到达,且无法传输文件结束条件。请注意,打开此地址通常会阻塞,直到客户端连接。
Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4,IP6 选项组: FD, SOCKET, LISTEN, CHILD, RANGE, IP4, IP6
Useful options:
fork,
bind,
range,
pf 有用的选项:fork、bind、range、pf
See also:
UDP,
UDP4-LISTEN,
UDP6-LISTEN,
TCP-LISTEN 另请参阅:UDP、UDP4-LISTEN、UDP6-LISTEN、TCP-LISTEN
UDP4-LISTEN:<port>
Like UDP-LISTEN, but only support IPv4
protocol. 类似于 UDP-LISTEN,但仅支持 IPv4 协议。
Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4 选项组: FD, SOCKET, LISTEN, CHILD, RANGE, IP4
UDP6-LISTEN:<port>
Like UDP-LISTEN, but only support IPv6
protocol. 类似于 UDP-LISTEN,但仅支持 IPv6 协议。
Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP6 选项组: FD, SOCKET, LISTEN, CHILD, RANGE, IP6
UDP-SENDTO:<host>:<port>
Communicates with the specified peer socket, defined by <port> [UDP
service] on
<host> [IP address], using UDP/IP version 4 or 6
depending on address specification, name resolution, or option
pf. 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. 与指定的对等套接字通信,由<port> [UDP 服务] 在<host> [IP 地址] 上定义,使用基于地址规范、名称解析或选项 pf 的 UDP/IP 版本 4 或 6。它仅向该对等套接字发送数据包并从该对等套接字接收数据包。该地址有效地实现了一个数据报客户端。它与 socat UDP-RECVFROM 和 UDP-RECV 地址对配合良好。
Option groups: FD,SOCKET,IP4,IP6 选项组:FD、SOCKET、IP4、IP6
Useful options:
ttl,
tos,
bind,
sourceport,
pf 有用的选项:ttl、tos、bind、sourceport、pf
See also:
UDP4-SENDTO,
UDP6-SENDTO,
UDP-RECVFROM,
UDP-RECV,
UDP-CONNECT,
UDP-LISTEN,
IP-SENDTO 参见:UDP4-SENDTO,UDP6-SENDTO,UDP-RECVFROM,UDP-RECV,UDP-CONNECT,UDP-LISTEN,IP-SENDTO
UDP4-SENDTO:<host>:<port>
Like UDP-SENDTO, but only supports IPv4
protocol. 类似于 UDP-SENDTO,但仅支持 IPv4 协议。
Option groups: FD,SOCKET,IP4 选项组:FD,SOCKET,IP4
UDP6-SENDTO:<host>:<port>
Like UDP-SENDTO, but only supports IPv6
protocol. 类似于 UDP-SENDTO,但仅支持 IPv6 协议。
Option groups: FD,SOCKET,IP6 选项组:FD,SOCKET,IP6
UDP-RECVFROM:<port>
Creates a UDP socket on <port> [UDP service] using
UDP/IP version 4 or 6
depending on option pf.
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 UDP-SENDTO address peers. 使用 UDP/IP 版本 4 或 6(取决于选项 pf)在<port> [UDP 服务]上创建一个 UDP 套接字。它从未指定的对等方接收一个数据包,并可能向该对等方发送一个或多个应答数据包。此模式特别适用于每个到达数据包(来自任意对等方)都由自己的子进程处理的 fork 选项。这允许类似于典型基于 UDP 的服务器(如 ntpd 或 named)的行为。此地址与 socat UDP-SENDTO 地址对等方配合良好。 Note: When the second address fails before entering the transfer loop the
packet is dropped. Use option retry or
forever on the second address to avoid data loss.
注意: 当第二个地址在进入传输循环之前失败时,数据包将被丢弃。在第二个地址上使用选项 retry 或 forever 以避免数据丢失。
Option groups: FD,SOCKET,IP4,IP6,CHILD,RANGE 选项组: FD, SOCKET, IP4, IP6, CHILD, RANGE
Useful options:
fork,
ttl,
tos,
bind,
sourceport,
pf 有用的选项: fork, ttl, tos, bind, sourceport, pf
See also:
UDP4-RECVFROM,
UDP6-RECVFROM,
UDP-SENDTO,
UDP-RECV,
UDP-CONNECT,
UDP-LISTEN,
IP-RECVFROM,
UNIX-RECVFROM 参见:UDP4-RECVFROM,UDP6-RECVFROM,UDP-SENDTO,UDP-RECV,UDP-CONNECT,UDP-LISTEN,IP-RECVFROM,UNIX-RECVFROM
UDP4-RECVFROM:<port>
Like UDP-RECVFROM, but only supports IPv4 protocol. 类似于 UDP-RECVFROM,但仅支持 IPv4 协议。
Option groups: FD,SOCKET,IP4,CHILD,RANGE 选项组:FD,SOCKET,IP4,CHILD,RANGE
UDP6-RECVFROM:<port>
Like UDP-RECVFROM, but only supports IPv6 protocol. 类似于 UDP-RECVFROM,但仅支持 IPv6 协议。
Option groups: FD,SOCKET,IP6,CHILD,RANGE 选项组:FD,SOCKET,IP6,CHILD,RANGE
UDP-RECV:<port>
Creates a UDP socket on <port> [UDP service] using UDP/IP version 4 or 6
depending on option pf.
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. 在<port> [UDP 服务]上创建一个 UDP 套接字,根据选项 pf 使用 UDP/IP 版本 4 或 6。它从多个未指定的对等方接收数据包并合并数据。不可能进行回复。它与例如 socat UDP-SENDTO 地址对等方一起工作良好;它的行为类似于 syslog 服务器。
This is a read-only address, see options -u and
-U, and dual addresses. 这是一个只读地址,查看选项 -u 和 -U,以及双地址。
Note: if you need the fork option, use UDP-RECVFROM in unidirectional mode (with option -u) instead. 注意: 如果您需要 fork 选项,请改用单向模式下的 UDP-RECVFROM(使用选项 -u)。
Option groups: FD,SOCKET,IP4,IP6,RANGE 选项组: FD, SOCKET, IP4, IP6, RANGE
Useful options:
pf,
bind,
sourceport,
ttl,
tos 有用的选项:pf、bind、sourceport、ttl、tos
See also:
UDP4-RECV,
UDP6-RECV,
UDP-SENDTO,
UDP-RECVFROM,
UDP-CONNECT,
UDP-LISTEN,
IP-RECV,
UNIX-RECV 另请参阅:UDP4-RECV、UDP6-RECV、UDP-SENDTO、UDP-RECVFROM、UDP-CONNECT、UDP-LISTEN、IP-RECV、UNIX-RECV
UDP4-RECV:<port>
Like UDP-RECV, but only supports IPv4 protocol. 类似于 UDP-RECV,但仅支持 IPv4 协议。
Option groups: FD,SOCKET,IP4,RANGE 选项组: FD, SOCKET, IP4, RANGE
UDP6-RECV:<port>
Like UDP-RECV, but only supports IPv6 protocol. 类似于 UDP-RECV,但仅支持 IPv6 协议。
Option groups: FD,SOCKET,IP6,RANGE 选项组: FD, SOCKET, IP6, RANGE
UDPLITE-CONNECT:<host>:<port>
UDPLITE4-CONNECT:<host>:<port>
UDPLITE6-CONNECT:<host>:<port>
UDPLITE-DATAGRAM:<address>:<port>
UDPLITE4-DATAGRAM:<address>:<port>
UDPLITE6-DATAGRAM:<address>:<port>
UDPLITE-LISTEN:<port>
UDPLITE4-LISTEN:<port>
UDPLITE6-LISTEN:<port>
UDPLITE-SENDTO:<host>:<port>
UDPLITE4-SENDTO:<host>:<port>
UDPLITE6-SENDTO:<host>:<port>
UDPLITE-RECVFROM:<port>
UDPLITE4-RECVFROM:<port>
UDPLITE6-RECVFROM:<port>
UDPLITE-RECV:<port>
UDPLITE4-RECV:<port>
UDPLITE6-RECV:<port>
The UDPLITE addresses are almost identical to the related UDP addresses
but they use UDP-Lite protocol and have the additional UDPLITE option
group. UDPLITE 地址几乎与相关的 UDP 地址相同,但它们使用 UDP-Lite 协议,并具有额外的 UDPLITE 选项组。
UNIX-CONNECT:<filename>
Connects to <filename> assuming it is a UNIX domain
socket.
If <filename> does not exist, this is an error;
if <filename> is not a UNIX domain socket, this is an error;
if <filename> is a UNIX domain socket, but no process is listening, this is
an error. 连接到<filename>,假设它是一个 UNIX 域套接字。如果<filename>不存在,则会出错;如果<filename>不是 UNIX 域套接字,则会出错;如果<filename>是 UNIX 域套接字,但没有进程在监听,则会出错。
Option groups: FD,SOCKET,NAMED,RETRY,UNIX 选项组:FD,SOCKET,NAMED,RETRY,UNIX )
Useful options:
bind ) 有用的选项: bind
See also:
UNIX-LISTEN,
UNIX-SENDTO,
TCP 另请参阅: UNIX-LISTEN, UNIX-SENDTO, TCP
UNIX-LISTEN:<filename>
Listens on <filename> using a UNIX domain stream
socket and accepts a connection.
If <filename> exists and is not a socket, this is an error.
If <filename> 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) (example). 使用 UNIX 域流套接字在 <filename> 上侦听并接受连接。如果 <filename> 存在且不是套接字,则会出错。如果 <filename> 存在且是 UNIX 域套接字,则绑定到该地址会失败(使用选项 unlink-early!)。请注意,通常打开此地址会阻塞,直到客户端连接。从 socat 版本 1.4.3 开始,关闭此地址时会删除文件系统条目(但请参阅选项 unlink-close)(示例)。
Option groups: FD,SOCKET,NAMED,LISTEN,CHILD,RETRY,UNIX 选项组: FD, SOCKET, NAMED, LISTEN, CHILD, RETRY, UNIX
Useful options:
fork,
umask,
mode,
user,
group,
unlink-early 有用的选项: fork, umask, mode, user, group, unlink-early
See also:
UNIX-CONNECT,
UNIX-RECVFROM,
UNIX-RECV,
TCP-LISTEN 另请参阅: UNIX-CONNECT, UNIX-RECVFROM, UNIX-RECV, TCP-LISTEN
UNIX-SENDTO:<filename>
Communicates with the specified peer socket, defined by [<filename>] assuming it is a UNIX domain datagram socket.
It sends packets to and receives packets from that peer socket only.
Please note that it might be necessary to bind the
local socket to an address (e.g. /tmp/sock1, which must not exist
before).
This address type works well with socat UNIX-RECVFROM and UNIX-RECV address
peers. 与指定的对等套接字通信,由 [ ] 定义,假设它是 UNIX 域数据报套接字。它只向该对等套接字发送数据包并从该对等套接字接收数据包。请注意,可能需要将本地套接字绑定到一个地址(例如 /tmp/sock1 ,在此之前不能存在)。此地址类型与 socat UNIX-RECVFROM 和 UNIX-RECV 地址对配合良好。
Option groups: FD,SOCKET,NAMED,UNIX 选项组:FD、SOCKET、NAMED、UNIX
Useful options:
bind 有用的选项:bind
See also:
UNIX-RECVFROM,
UNIX-RECV,
UNIX-CONNECT,
UDP-SENDTO,
IP-SENDTO 参见:UNIX-RECVFROM,UNIX-RECV,UNIX-CONNECT,UDP-SENDTO,IP-SENDTO
UNIX-RECVFROM:<filename>
Creates a UNIX domain datagram socket [<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. 创建一个 UNIX 域数据报套接字[<filename>]。接收一个数据包,并可能向对等方发送一个或多个应答数据包。此模式特别适用于具有 fork 选项的情况,其中每个到达的数据包 - 来自任意对等方 - 都由其自己的子进程处理。此地址与 socat UNIX-SENDTO 地址对等方配合良好。
Option groups: FD,SOCKET,NAMED,CHILD,UNIX 选项组:FD,SOCKET,NAMED,CHILD,UNIX
See the note about RECVFROM addresses. 查看有关 RECVFROM 地址的注释。
Useful options:
fork 有用的选项:fork umask
See also:
UNIX-SENDTO,
UNIX-RECV,
UNIX-LISTEN,
UDP-RECVFROM,
IP-RECVFROM 参见:UNIX-SENDTO,UNIX-RECV,UNIX-LISTEN,UDP-RECVFROM,IP-RECVFROM
UNIX-RECV:<filename>
Creates a UNIX domain datagram socket [<filename>].
Receives packets from multiple unspecified peers and merges the data.
No replies are possible, this is a read-only address, see options -u and
-U, and dual addresses.
It can be, e.g., addressed by socat UNIX-SENDTO address peers.
It behaves similar to a syslog server. 创建一个 UNIX 域数据报套接字[<filename>]。从多个未指定的对等方接收数据包并合并数据。无法回复,这是一个只读地址,参见选项-u 和-U,以及双地址。例如,可以通过 socat UNIX-SENDTO 地址对等方来寻址。它的行为类似于 syslog 服务器。
Option groups: FD,SOCKET,NAMED,UNIX 选项组:FD,SOCKET,NAMED,UNIX
Useful options:
umask 有用的选项:umask
See also:
UNIX-SENDTO,
UNIX-RECVFROM,
UNIX-LISTEN,
UDP-RECV,
IP-RECV 另请参阅:UNIX-SENDTO,UNIX-RECVFROM,UNIX-LISTEN,UDP-RECV,IP-RECV
UNIX-CLIENT:<filename>
Communicates with the specified peer socket, defined by
[<filename>] assuming it is a UNIX domain socket.
It first tries to connect and, if that fails, assumes it is a datagram
socket, thus supporting both types. 与指定的对等套接字通信,由[<filename>]定义,假定它是一个 UNIX 域套接字。它首先尝试连接,如果失败,则假定它是一个数据报套接字,因此支持两种类型。
Option groups: FD,SOCKET,NAMED,UNIX 选项组: FD, SOCKET, NAMED, UNIX
Useful options:
bind 有用选项: bind
See also:
UNIX-CONNECT,
UNIX-SENDTO,
GOPEN 另请参阅: UNIX-CONNECT, UNIX-SENDTO, GOPEN
VSOCK-CONNECT:<cid>:<port>
Establishes a VSOCK stream connection to the specified <cid> [VSOCK
cid] and <port> [VSOCK port]. 建立到指定的 <cid> [VSOCK cid] 和 <port> [VSOCK port] 的 VSOCK 流连接。
Option groups: FD,SOCKET,CHILD,RETRY 选项组: FD, SOCKET, CHILD, RETRY
Useful options:
bind,
connect-timeout,
retry,
readbytes 有用的选项: bind, connect-timeout, retry, readbytes
See also:
VSOCK-LISTEN,
查看也: VSOCK-LISTEN
VSOCK-LISTEN:<port>
Listens on <port> [VSOCK port] and accepts a
VSOCK connection.
Note that opening this address usually blocks until a client connects. 在 <端口> [VSOCK 端口] 上监听,并接受 VSOCK 连接。请注意,打开此地址通常会阻塞,直到客户端连接。
Option groups: FD,SOCKET,LISTEN,CHILD,RETRY 选项组: FD, SOCKET, LISTEN, CHILD, RETRY
Useful options:
fork,
bind,
max-children,
backlog,
su,
reuseaddr,
retry 有用的选项:fork、bind、max-children、backlog、su、reuseaddr、retry
See also:
VSOCK-CONNECT 另请参阅:VSOCK-CONNECT
ABSTRACT-CONNECT:<string>
ABSTRACT-LISTEN:<string>
ABSTRACT-SENDTO:<string>
ABSTRACT-RECVFROM:<string>
ABSTRACT-RECV:<string>
ABSTRACT-CLIENT:<string>
The ABSTRACT addresses are almost identical to the related UNIX addresses
except that they do not address file system based sockets but an alternate
UNIX domain address space. To achieve 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. 抽象地址与相关的 UNIX 地址几乎相同,只是它们不是针对基于文件系统的套接字,而是针对另一个 UNIX 域地址空间。为了实现这一点,套接字地址字符串在内部以 "\0" 为前缀。此功能仅在 Linux 上可用(?)。选项组与相关的 UNIX 地址相同,只是抽象地址不属于 NAMED 组。
Useful options:
netns 有用的选项:netns
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 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 option -g).
由于技术原因,并非每个选项都可以应用于每种地址类型;例如,将套接字选项应用于常规文件将失败。为了在打开阶段尽早捕捉大多数无用的组合,引入了选项组的概念。每个选项属于一个或多个选项组。选项只能与支持其至少一个选项组的地址类型一起使用(但请参见选项 -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.
Some address options manipulate parameters of system calls;
e.g., option sync sets the
O_SYNC
flag with the
open()
call.
Other options cause a system or library call; e.g., with option `ttl=value'
the
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
chroot()
call.
地址选项具有其值必须符合的数据类型。每个地址选项仅由关键字或关键字后跟“=值”组成,其中值必须符合选项类型。一些地址选项操作系统调用的参数;例如,选项 sync 使用 O_SYNC 调用设置 open() 标志。其他选项会导致系统或库调用;例如,使用选项 `ttl=value' 会应用 setsockopt(fd, SOL_IP, IP_TTL, value, sizeof(int)) 调用。其他选项设置用于数据传输期间的内部 socat 变量;例如,`crnl' 导致显式字符转换。一些选项具有更复杂的实现;例如,su-d(substuser-delayed)查询一些用户和组信息,存储它们,并在可能的 chroot() 调用后稍后应用它们。
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 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.
如果一个地址有多个选项,它们在地址规范中的顺序几乎不会影响它们的执行/应用顺序。相反,socat 内置了一个选项阶段模型,试图将选项按照有用的顺序排列。一些选项以不同形式存在(例如,unlink,unlink-early,unlink-late)以控制它们执行的时间。
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
setsockopt()
cause multiple
invocations. With options that set parameters for a required call like
open()
or set internal flags, the value of the last option occurrence is effective.
如果在一个地址规范中多次指定相同的选项,无论值相同还是不同,效果取决于选项的类型。导致函数调用的选项(如 setsockopt() )会导致多次调用。对于设置必需调用参数的选项(如 open() )或设置内部标志的选项,最后一个选项出现的值有效。
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.
许多选项的存在或语义取决于系统。Socat 通常不会尝试模拟缺失的 libc 或内核功能,它只是提供对底层系统的接口。因此,如果操作系统缺少某个功能,则相关选项在该平台上简单地不可用。
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 xio.help.
以下段落仅介绍更常见的地址选项。要获取更全面的参考资料,并查找有关规范选项名称、别名、选项阶段和平台的信息,请参阅文件 xio.help。
FD option group FD 选项组
This option group contains options that are applied to a UN*X
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. 此选项组包含应用于 UNIX 风格文件描述符的选项,无论它是如何生成的。由于所有当前的 socat 地址类型都是基于文件描述符的,这些选项可以应用于任何地址。
Note: Some of these options are also member of another option group, that
provides another, 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.
注意: 这些选项中的一些也是另一个选项组的成员,该选项组提供另一种非 fd 基础机制。对于这些选项,取决于实际地址类型及其选项组使用哪种机制。第二种非 fd 基础机制被优先使用。
cloexec[=<bool>]
Sets the
FD_CLOEXEC
flag with the
fcntl()
system call to value
<bool>. If set,
the file descriptor is closed on
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.
使用 fcntl() 系统调用将 FD_CLOEXEC 标志设置为值。如果设置了该标志,则在 exec() 族函数调用时关闭文件描述符。Socat 在内部处理其控制的 fds 的此标志,因此在大多数情况下不需要应用此选项。
setlk[=<bool>]
Tries to set a discretionary write lock to the whole file using the
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.
尝试使用 fcntl(fd,
F_SETLK, ...) 系统调用对整个文件设置自由写锁。如果文件已被锁定,则此调用将导致错误。在 Linux 上,当组的文件权限为"S"(g-x,g+s),并且文件系统在本地挂载时使用"mand"选项时,锁是强制性的,即阻止其他进程打开文件。
setlkw[=<bool>]
Tries to set a discretionary waiting write lock to the whole file using the
fcntl(fd, F_SETLKW, ...)
system call. If the file is already locked,
this call blocks.
See option setlk for information about making this
lock mandatory.
尝试使用 fcntl(fd, F_SETLKW, ...) 系统调用将自由等待写锁设置为整个文件。如果文件已被锁定,此调用将被阻塞。有关使此锁定变为强制的信息,请参阅选项 setlk。
setlk-rd[=<bool>]
Tries to set a discretionary read lock to the whole file using the
fcntl(fd,
F_SETLK, ...)
system call. If the file is already write locked, this call
results in an error.
See option setlk for information about making this
lock mandatory.
尝试使用 fcntl(fd,
F_SETLK, ...) 系统调用将自由读锁设置为整个文件。如果文件已被写锁定,此调用将导致错误。有关使此锁定变为强制的信息,请参阅选项 setlk。
setlkw-rd[=<bool>]
Tries to set a discretionary waiting read lock to the whole file using the
fcntl(fd, F_SETLKW, ...)
system call. If the file is already write
locked, this call blocks.
See option setlk for information about making this
lock mandatory.
尝试使用 fcntl(fd, F_SETLKW, ...) 系统调用将自由等待读锁设置为整个文件。如果文件已被写锁定,此调用将被阻塞。有关使此锁定变为强制的信息,请参阅选项 setlk。
flock-ex[=<bool>]
Tries to set a blocking exclusive advisory lock to the file using the
flock(fd, LOCK_EX)
system call. Socat hangs in this call if the file
is locked by another process.
尝试使用 flock(fd, LOCK_EX) 系统调用对文件设置阻塞独占性咨询锁。如果文件被另一个进程锁定,Socat 在此调用中会挂起。
flock-ex-nb[=<bool>]
Tries to set a nonblocking exclusive advisory lock to the file using the
flock(fd, LOCK_EX|LOCK_NB)
system call. If the file is already locked,
this option results in an error.
尝试使用 flock(fd, LOCK_EX|LOCK_NB) 系统调用对文件设置非阻塞独占性咨询锁。如果文件已被锁定,此选项会导致错误。
flock-sh[=<bool>]
Tries to set a blocking shared advisory lock to the file using the
flock(fd, LOCK_SH)
system call. Socat hangs in this call if the file
is locked by another process.
尝试使用 flock(fd, LOCK_SH) 系统调用对文件设置阻塞共享咨询锁。如果文件被另一个进程锁定,Socat 在此调用中会挂起。
flock-sh-nb[=<bool>]
Tries to set a nonblocking shared advisory lock to the file using the
flock(fd, LOCK_SH|LOCK_NB)
system call. If the file is already locked,
this option results in an error.
尝试使用 flock(fd, LOCK_SH|LOCK_NB) 系统调用对文件设置非阻塞共享咨询锁。如果文件已被锁定,此选项将导致错误。
lock[=<bool>]
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.
对文件设置阻塞锁。根据特定平台上的可用性使用 setlk 或 flock 机制。如果两者都可用,则使用 POSIX 变体(setlkw)。
user=<user>
Sets the <user> (owner) of the stream.
If the address is member of the NAMED option group,
socat uses the
chown()
system call after opening the
file or binding to the UNIX domain socket (race condition!).
Without filesystem entry, socat sets the user of the stream
using the
fchown()
system call.
These calls might require root privilege.
设置流的 (所有者)。如果地址是 NAMED 选项组的成员,socat 在打开文件或绑定到 UNIX 域套接字后使用 chown() 系统调用(竞争条件!)。没有文件系统条目,socat 使用 fchown() 系统调用设置流的用户。这些调用可能需要 root 权限。
user-late=<user>
Sets the owner of the fd to <user> with the
fchown()
system call after opening
or connecting the channel.
This is useful only on file system entries.
将 fd 的所有者设置为 ,在打开或连接通道后使用 fchown() 系统调用。这仅适用于文件系统条目。
group=<group>
Sets the <group> of the stream.
If the address is member of the NAMED option group,
socat uses the
chown()
system call after opening the
file or binding to the UNIX domain socket (race condition!).
Without filesystem entry, socat sets the group of the stream
with the
fchown()
system call.
These calls might require group membership or root privilege.
设置流的 。如果地址是 NAMED 选项组的成员,socat 在打开文件或绑定到 UNIX 域套接字后使用 chown() 系统调用(竞争条件!)。没有文件系统条目,socat 使用 fchown() 系统调用设置流的组。这些调用可能需要组成员资格或 root 权限。
group-late=<group>
Sets the group of the fd to <group> with the
fchown()
system call after opening
or connecting the channel.
This is useful only on file system entries.
将 fd 的组设置为 ,在打开或连接通道后使用 fchown() 系统调用。这仅适用于文件系统条目。
mode=<mode>
Sets the <mode> [mode_t] (permissions) of the stream.
If the address is member of the NAMED option group and
uses the
open()
or
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
chmod()
system call after opening the
filesystem entry or binding to the UNIX domain socket (race condition!).
Otherwise, socat sets the mode of the stream
using
fchmod()
.
These calls might require ownership or root privilege.
设置流的 [ mode_t](权限)。如果地址是 NAMED 选项组的成员并使用 open() 或 creat() 调用,则使用这些应用模式。如果地址是 NAMED 选项组的成员,而没有使用这些系统调用,socat 在打开文件系统条目或绑定到 UNIX 域套接字后使用 chmod() 系统调用(竞争条件!)。否则,socat 使用 fchmod() 设置流的模式。这些调用可能需要所有权或根权限。
perm-late=<mode>
Sets the permissions of the fd to value <mode>
[mode_t] using the
fchmod()
system call after
opening or connecting the channel.
This is useful only on file system entries.
使用 fchmod() 系统调用将 fd 的权限设置为值 [ mode_t],在打开或连接通道后。这仅对文件系统条目有用。
append[=<bool>]
Always writes data to the actual end of file.
If the address is member of the OPEN option group,
socat uses the
O_APPEND
flag with the
open()
system call
(example).
Otherwise, socat applies the
fcntl(fd, F_SETFL, O_APPEND)
call.
始终将数据写入实际文件末尾。如果地址是 OPEN 选项组的成员,socat 使用 O_APPEND 标志与 open() 系统调用(示例)。否则,socat 应用 fcntl(fd, F_SETFL, O_APPEND) 调用。
nonblock[=<bool>]
Tries to open or use file in nonblocking mode. Its only effects are that the
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
O_NONBLOCK
flag with the
open()
system call.
Otherwise, socat applies the
fcntl(fd, F_SETFL, O_NONBLOCK)
call.
尝试以非阻塞模式打开或使用文件。它的唯一效果是 TCP 地址的调用不会阻塞,并且打开命名管道进行读取不会阻塞。如果地址是 OPEN 选项组的成员,socat 使用 O_NONBLOCK 标志与 open 系统调用。否则,socat 应用 open 调用。
binary[=<bool>]
Opens the file in binary mode to avoid implicit line terminator
conversions (Cygwin).
以二进制模式打开文件,以避免隐式换行符转换(Cygwin)。
text[=<bool>]
Opens the file in text mode to force implicit line terminator conversions
(Cygwin).
以文本模式打开文件,强制隐式换行符转换(Cygwin)。
noinherit[=<bool>]
Does not keep this file open in a spawned process (Cygwin).
不要在生成的进程(Cygwin)中保持此文件打开。
cool-write[=<bool>]
Takes it easy when write fails with EPIPE or ECONNRESET and logs the message
with notice level instead of 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. Use this option only with option
fork because otherwise it might cause socat to exit
with code 0 even on failure. 当写操作失败时,以 EPIPE 或 ECONNRESET 并使用通知级别记录消息,而不是错误级别。 这可以防止在 socat 用作高容量服务器或代理时客户端经常中止连接时,日志文件被填满无用的错误消息。 仅在选项 fork 的情况下使用此选项,否则可能导致 socat 即使失败也以代码 0 退出。
This option is deprecated, consider using
option children-shutup instead.
此选项已弃用,请考虑改用选项 children-shutup。
end-close[=<bool>]
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 (example). 更改(地址相关)结束连接的方法,仅关闭文件描述符。当连接将被其他进程重用或共享时,这是有用的(示例)。
Normally, socket connections will be ended with shutdown(2) which
terminates the socket even if it is shared by multiple processes.
close(2) "unlinks" the socket from the process but keeps it active as
long as there are still links from other processes. 通常,套接字连接将以 shutdown(2) 结束,即使它被多个进程共享也会终止套接字。 close(2) 会将套接字从进程中“取消链接”,但只要其他进程仍有链接,它就会保持活动状态。
Similarly, when an address of type EXEC or SYSTEM is ended, socat usually
will explicitly kill the sub process. With this option, it will just close
the file descriptors.
类似地,当类型为 EXEC 或 SYSTEM 的地址结束时,socat 通常会显式杀死子进程。使用此选项,它将仅关闭文件描述符。
shut-none[=<bool>]
Changes the (address dependent) method of shutting down the write part of a
connection to not do anything.
更改关闭连接写部分的方法(与地址有关),不执行任何操作。
shut-down[=<bool>]
Changes the (address dependent) method of shutting down the write part of a
connection to shutdown(fd, SHUT_WR). Is only useful with sockets.
更改关闭连接写部分的方法(与地址有关),使用 shutdown(fd, SHUT_WR)。仅适用于套接字。
shut-close[=<bool>]
Changes the (address dependent) method of shutting down the write part of a
connection to close(fd).
更改关闭连接写部分的方法(与地址有关),使用 close(fd)。
shut-null[=<bool>]
When one address indicates EOF, socat will send a zero sized packet to the
write channel of the other address to transfer the EOF condition. This is
useful with UDP and other datagram protocols. Has been tested against
netcat and socat with option null-eof.
当一个地址指示 EOF 时,socat 将向另一个地址的写通道发送一个大小为零的数据包,以传输 EOF 条件。这在 UDP 和其他数据报协议中很有用。已针对 netcat 和 socat 以选项 null-eof 进行了测试。
null-eof[=<bool>]
Normally socat will ignore empty (zero size payload) packets arriving on
datagram sockets, so it survives port scans. With this option socat
interprets empty datagram packets as EOF indicator (see
shut-null).
通常情况下,socat 会忽略在数据报套接字上到达的空(零大小负载)数据包,因此可以抵御端口扫描。使用此选项,socat 将空数据报数据包解释为 EOF 指示器(参见 shut-null)。
ioctl-void=<request>
Calls ioctl() with the request value as second argument and NULL as
third argument. This option allows utilizing ioctls that are not
explicitly implemented in socat.
使用请求值作为第二个参数,NULL 作为第三个参数调用 ioctl() 。此选项允许利用在 socat 中未明确实现的 ioctl。
ioctl-int=<request>:<value>
Calls ioctl() with the request value as second argument and the integer
value as third argument.
使用请求值作为第二个参数和整数值作为第三个参数调用 ioctl() 。
ioctl-intp=<request>:<value>
Calls ioctl() with the request value as second argument and a pointer to
the integer value as third argument.
使用请求值作为第二个参数和指向整数值的指针作为第三个参数调用 ioctl() 。
ioctl-bin=<request>:<value>
Calls ioctl() with the request value as second argument and a pointer to
the given data value as third argument. This data must be specified in
<dalan> form.
使用请求值作为第二个参数和指向给定数据值的指针作为第三个参数调用 ioctl() 。此数据必须以形式指定。
ioctl-string=<request>:<value>
Calls ioctl() with the request value as second argument and a pointer to
the given string as third argument.
<dalan> form.
使用请求值作为第二个参数,并将给定字符串的指针作为第三个参数调用 ioctl() 。形式。
NAMED option group NAMED 选项组
These options work on file system entries. 这些选项适用于文件系统条目。
Please note that, with UNIX domain client addresses, this means the bind entry,
not the target/peer entry. 请注意,对于 UNIX 域客户端地址,这意味着绑定条目,而不是目标/对等条目。
See also options user, group, and
mode.
另请参阅选项用户、组和模式。
user-early=<user>
Changes the <user> (owner) of the file system entry before
accessing it, using the
chown()
system call. This call might require root privilege.
在访问文件系统条目之前,使用 chown() 系统调用更改文件的 (所有者)。此调用可能需要 root 权限。
group-early=<group>
Changes the <group> of the file system entry before
accessing it, using the
chown()
system call. This call might require group membership or root
privilege.
在访问文件系统条目之前,使用 chown() 系统调用更改文件系统条目的。此调用可能需要组成员资格或根特权。
perm-early=<mode>
Changes the <mode> [mode_t] of the file system entry
before accessing it, using the
chmod()
system call. This call might require ownership or root
privilege.
在访问文件系统条目之前,使用 chmod() 系统调用更改文件系统条目的 [mode_t]。此调用可能需要所有权或根特权。
unlink-early[=<bool>]
Unlinks (removes) the file before opening it and even before applying
user-early etc.
在打开文件之前甚至在应用用户早期等之前取消链接(删除)文件。
unlink[=<bool>]
Unlinks (removes) the file before accessing it, but after user-early etc.
在访问文件之前取消链接(删除)文件,但在用户早期等之后。
unlink-late[=<bool>]
Unlinks (removes) the file after opening it to make it inaccessible for
other processes after a short race condition.
在打开文件后取消链接(删除)文件,以使其他进程在短暂的竞争条件后无法访问该文件。
unlink-close[=<bool>]
Controls removal of the addresses file system entry when closing the address.
For named pipes,
UNIX domain sockets,
and the symbolic links of pty addresses,
the default is remove (1); for created files,
opened files, and
generic opened files the default is keep (0).
Setting this option to 1 removes the entry, 0 keeps it. No value means 1.
在关闭地址时控制地址文件系统条目的移除。对于命名管道、UNIX 域套接字和 pty 地址的符号链接,默认值为 remove(1);对于创建的文件、已打开的文件和通用已打开的文件,默认值为 keep(0)。将此选项设置为 1 将删除该条目,0 将保留该条目。没有值表示为 1。
OPEN option group 打开选项组
The OPEN group options allow setting flags with the
open()
system call.
E.g., option `creat' sets the
O_CREAT
flag. When the used address does
not use
open()
(e.g.STDIO), the
fcntl(..., F_SETFL, ...)
call is
used instead. 打开组选项允许使用 open() 系统调用设置标志。例如,选项`creat'设置 O_CREAT 标志。当使用的地址不使用 open() (例如 STDIO)时,将改用 fcntl(..., F_SETFL, ...) 调用。
See also options append and
nonblock.
另请参阅选项 append 和 nonblock。
creat[=<bool>]
Creates the file if it does not exist (example).
如果文件不存在,则创建文件(示例)。
dsync[=<bool>]
Blocks
write()
calls until metainfo is physically written to media.
阻止 write() 调用,直到元信息被物理写入媒体为止。
excl[=<bool>]
With option creat, if file exists this is an error.
使用 creat 选项,如果文件存在,则会报错。
largefile[=<bool>]
On 32 bit systems, allows a file larger than 2^31 bytes.
在 32 位系统上,允许文件大小超过 2^31 字节。
noatime[=<bool>]
Sets the O_NOATIME options, so reads do not change the access timestamp.
设置 O_NOATIME 选项,因此读取不会更改访问时间戳。
noctty[=<bool>]
Does not make this file the controlling terminal.
不将此文件设置为控制终端。
nofollow[=<bool>]
Does not follow symbolic links.
不遵循符号链接。
nshare[=<bool>]
Does not allow sharing this file with other processes.
不允许与其他进程共享此文件。
rshare[=<bool>]
Does not allow other processes to open this file for writing.
不允许其他进程打开此文件进行写操作。
rsync[=<bool>]
Blocks
write()
until metainfo is physically written to media.
阻塞 write() 直到元信息被物理写入媒体。
sync[=<bool>]
Blocks
write()
until data is physically written to media.
阻塞 write() 直到数据被物理写入媒体。
rdonly[=<bool>]
Opens the file for reading only.
仅打开文件以供读取。
wronly[=<bool>]
Opens the file for writing only.
仅打开文件进行写入。
trunc[=<bool>]
Truncates the file to size 0 during opening it.
在打开文件时将文件截断为大小为 0。
REG and BLK option group REG 和 BLK 选项组。
These options are usually applied to a UN*X file descriptor, but their
semantics make sense only on a file supporting random access.
这些选项通常应用于 UN*X 文件描述符,但它们的语义只在支持随机访问的文件上才有意义。
seek=<offset>
Applies the
lseek(fd, <offset>, SEEK_SET)
(or
lseek64
) system
call, thus positioning the file pointer absolutely to <offset>
[off_t or off64_t]. Please note that a
missing value defaults to 1, not 0.
应用 lseek(fd, <offset>, SEEK_SET) (或 lseek64 )系统调用,因此将文件指针绝对定位到 [off_t 或 off64_t]。请注意,缺少值默认为 1,而不是 0。
seek-cur=<offset>
Applies the
lseek(fd, <offset>, SEEK_CUR)
(or
lseek64
) system
call, thus positioning the file pointer <offset> [off_t or
off64_t] bytes relatively to its current position (which
is usually 0). Please note that a missing value defaults to 1, not 0.
应用 lseek(fd, <offset>, SEEK_CUR) (或 lseek64 )系统调用,因此将文件指针 [off_t 或 off64_t] 字节相对于其当前位置(通常为 0)定位。请注意,缺少值默认为 1,而不是 0。
seek-end=<offset>
Applies the
lseek(fd, <offset>, SEEK_END)
(or
lseek64
) system
call, thus positioning the file pointer <offset> [off_t or
off64_t] bytes relatively to the files current end. Please
note that a missing value defaults to 1, not 0.
应用 lseek(fd, <offset>, SEEK_END) (或 lseek64 )系统调用,从而将文件指针 [ off_t 或 off64_t]字节相对于文件当前末尾定位。请注意,缺少值默认为 1,而不是 0。
ftruncate=<offset>
Applies the
ftruncate(fd, <offset>)
(or
ftruncate64
if available) system call, thus
truncating the file at the position <offset> [off_t or
off64_t]. Please note that a missing value defaults to 1,
not 0.
应用 ftruncate(fd, <offset>) (或 ftruncate64 如果可用)系统调用,从而将文件截断到位置 [ off_t 或 off64_t]。请注意,缺少值默认为 1,而不是 0。
secrm[=<bool>]
unrm[=<bool>]
compr[=<bool>]
fs-sync[=<bool>]
immutable[=<bool>]
fs-append[=<bool>]
nodump[=<bool>]
fs-noatime[=<bool>]
journal-data[=<bool>]
notail[=<bool>]
dirsync[=<bool>]
These options change non standard file attributes on operating systems and
file systems that support these features, like Linux with ext2fs and
successors, xfs, 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.
这些选项会更改支持这些功能的操作系统和文件系统上的非标准文件属性,例如具有 ext2fs 和后继版本的 Linux,xfs 或 reiserfs。有关这些选项的信息,请参阅 man 1 chattr。请注意,在创建文件和应用这些选项之间可能存在竞争条件。
PIPE options 管道选项
These options may be applied to pipes (fifos).
这些选项可以应用于管道(先进先出)。
f-setpipe-sz=<int>
setpipe=<int>
Set the number of bytes a pipe can buffer. Where more bytes are written the
writing process might block. When more bytes are written in a single
write() the writing process blocks and might never recover.
设置管道可以缓冲的字节数。当写入更多字节时,写入进程可能会阻塞。当在单个 write() 中写入更多字节时,写入进程会阻塞,可能永远无法恢复。
General address options 通用地址选项
These options may be applied to all address types. They change some process
properties that are restored after opening the address.
这些选项可以应用于所有地址类型。它们会更改一些在打开地址后恢复的进程属性。
chdir=<filename>
cd=<filename>
Changes the working directory. After opening the address the master process
changes back to the original working directory. Sub processes inherit the
temporary setting.
更改工作目录。打开地址后,主进程会切换回原始工作目录。子进程会继承临时设置。
umask=<mode>
Sets the umask of the process to <mode> [mode_t] before
opening the address. Useful when file system entries are created or a shell
or program is invoked. Usually the value is specified as octal number. 将进程的 umask 设置为 <mode> [ mode_t],然后再打开地址。在创建文件系统条目或调用 shell 或程序时非常有用。通常该值以八进制数指定。
The processes umask value is inherited by child processes.
Note: umask is an inverted value: creating a file with umask=0026 results in
permissions 0640.
进程的 umask 值会被子进程继承。注意:umask 是一个反转的值:使用 umask=0026 创建文件会得到权限 0640。
PROCESS option group PROCESS 选项组
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.
此组的选项更改进程属性,而不仅仅影响一个数据通道。对于 EXEC 和 SYSTEM 地址以及带有 fork 选项的 LISTEN 和 CONNECT 类型地址,这些选项适用于子进程,而不是主 socat 进程。
chroot=<directory>
Performs a
chroot()
operation to <directory>
after processing the address (example). This call might require root privilege.
在处理地址(示例)后,对 执行 chroot() 操作。此调用可能需要 root 权限。
chroot-early=<directory>
Performs a
chroot()
operation to <directory>
before opening the address. This call might require root privilege.
在打开地址之前,对 执行 chroot() 操作。此调用可能需要 root 权限。
setgid=<group>
Changes the primary <group> of the process after
processing the address. This call might require root privilege. Please note
that this option does not drop other group related privileges.
在处理地址后更改进程的主要<组>。此调用可能需要 root 权限。请注意,此选项不会删除其他与组相关的权限。
setgid-early=<group>
Like setgit but is performed before opening the address.
类似于 setgit,但是在打开地址之前执行。
setuid=<user>
Changes the <user> (owner) of the process after processing
the address. This call might require root privilege. Please note that this
option does not drop group related privileges. Check if option
su better fits your needs.
在处理地址后更改进程的<用户>(所有者)。此调用可能需要 root 权限。请注意,此选项不会删除与组相关的权限。检查选项 su 是否更适合您的需求。
setuid-early=<user>
Like setuid but is performed before opening the
address.
类似于 setuid,但是在打开地址之前执行。
su=<user>
Changes the <user> (owner) and groups of the process after
processing the address (example). This call might require root privilege.
在处理地址(示例)后更改进程的<user>(所有者)和组。此调用可能需要 root 权限。
su-d=<user>
Short name for substuser-delayed.
Changes the <user>
(owner) and groups of the process after processing the address (example).
The user and his groups are retrieved before a possible
chroot()
. This call might require root privilege.
substuser-delayed 的简短名称。在处理地址(示例)后更改进程的(所有者)和组。在可能的 chroot() 之前,用户及其组将被检索。此调用可能需要 root 权限。
setpgid=<pid_t>
Makes the process a member of the specified process group
<pid_t>. If no value
is given, or if the value is 0 or 1, the process becomes leader of a new
process group.
使进程成为指定进程组<pid_t>的成员。如果未给出值,或者值为 0 或 1,则该进程将成为新进程组的领导者。
setsid
Makes the process the leader of a new session (example).
使进程成为新会话的领导者(示例)。
netns=<net-namespace-name>
Before opening the address it tries to switch to the named network namespace.
After opening the address it switches back to the previous namespace.
(Example with TCP forwarder,
example with virtual network connection. 在打开地址之前,它尝试切换到命名的网络命名空间。打开地址后,它会切换回先前的命名空间。(具有 TCP 转发器的示例,具有虚拟网络连接的示例。
Only on Linux; requires root; use option --experimental. 仅适用于 Linux;需要 root 权限;使用选项 --experimental 。
READLINE option group READLINE 选项组
These options apply to the readline address type.
这些选项适用于 readline 地址类型。
history=<filename>
Reads and writes history from/to <filename> (example).
从/写入历史记录到 <文件名>(示例)。
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.
从版本 1.4.0 开始,默认情况下,socat 尝试确定一个提示 - 然后将其传递给 readline 调用 - 通过记住输出的最后一个不完整行。使用此选项,socat 不会将提示传递给 readline,因此它将在终端的第一列开始行编辑。
noecho=<pattern>
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.
(example)
为提示指定一个常规模式,防止以下输入行显示在屏幕上并添加到历史记录中。提示被定义为在最新的换行符之后和输入字符被键入之前的 readline 地址输出的文本。该模式是一个正则表达式,例如"^[Pp]assword:.*$"或"([Uu]ser:|[Pp]assword:)"。有关详细信息,请参阅 regex(7)。(示例)
prompt=<string>
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 achieved.
将字符串作为提示传递给 readline 函数。readline 在浏览历史记录时打印此提示。如果此字符串与另一个 socat 地址上由交互式程序发出的常量提示匹配,则可以实现一致的外观和感觉。
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
PROXY.
此组包含在数据级别起作用的选项。请注意,这些选项仅适用于 socat 传输的“原始”数据,而不适用于 PROXY 等地址使用的协议数据。
cr
Converts the default line termination character NL ('\n', 0x0a) to/from CR
('\r', 0x0d) when writing/reading on this channel.
将默认的换行符 NL('\n',0x0a)在此通道上写入/读取时转换为/从 CR('\r',0x0d)。
crnl
Converts the default line termination character NL ('\n', 0x0a) to/from CRNL
("\r\n", 0x0d0a) when writing/reading on this channel (example).
Note: socat simply strips all CR characters.
将默认的换行符 NL('\n',0x0a)在此通道上写入/读取时转换为/从 CRNL("\r\n",0x0d0a)(示例)。注意:socat 简单地剥离所有 CR 字符。
ignoreeof
When EOF occurs on this channel, socat ignores it and tries to read more
data (like "tail -f") (example).
当此通道发生 EOF 时,socat 会忽略它并尝试读取更多数据(类似于 "tail -f")(示例)。
readbytes=<bytes>
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.
socat 仅从此地址读取了这么多字节(该地址仅提供了这么多字节用于传输,并在之后假装已到达文件结尾)。必须大于 0。
lockfile=<filename>
If lockfile exists, exits with error. If lockfile does not exist, creates it
and continues, unlinks lockfile on exit.
如果锁文件存在,则退出并显示错误。如果锁文件不存在,则创建它并继续,在退出时取消链接锁文件。
waitlock=<filename>
If lockfile exists, waits until it disappears. When lockfile does not exist,
creates it and continues, unlinks lockfile on exit.
如果锁文件存在,则等待直到它消失。当锁文件不存在时,创建它并继续,在退出时取消链接锁文件。
escape=<int>
Specifies the numeric code of a character that triggers EOF on the input
stream. It is useful with a terminal in raw mode
(example).
指定触发输入流 EOF 的字符的数字代码。在原始模式下的终端中很有用(示例)。
SOCKET option group SOCKET 选项组
These options are intended for all kinds of sockets, e.g. IP or UNIX domain. Most are applied with a
setsockopt()
call.
这些选项适用于各种类型的套接字,例如 IP 或 UNIX 域。大多数与 setsockopt() 调用一起使用。
bind=<sockname>
Binds the socket to the given socket address using the
bind()
system
call. The form of <sockname> is socket domain dependent:
IP4 and IP6 allow the form [hostname|hostaddress][:(service|port)] (example),
VSOCK allows the form [cid][:(port)]. 使用 bind() 系统调用将套接字绑定到给定的套接字地址。 的形式取决于套接字域:IP4 和 IP6 允许形式[主机名|主机地址][:(服务|端口)](示例),VSOCK 允许形式[cid][:(端口)]。
See also: unix-bind-tempname 另请参阅:unix-bind-tempname
connect-timeout=<seconds>
Abort the connection attempt after <seconds> [timeval]
with error status.
在<seconds> [timeval]后以错误状态中止连接尝试。
so-bindtodevice=<interface>
Binds the socket to the given <interface>.
This option might require root privilege.
将套接字绑定到给定的<interface>。此选项可能需要 root 权限。
broadcast
For datagram sockets, allows sending to broadcast addresses and receiving
packets addressed to broadcast addresses.
对于数据报套接字,允许发送到广播地址并接收发送到广播地址的数据包。
debug
Enables socket debugging.
启用套接字调试。
dontroute
Only communicates with directly connected peers, does not use routers.
仅与直接连接的对等方通信,不使用路由器。
keepalive
Enables sending keepalives on the socket.
在套接字上启用发送保持活动。
linger=<seconds>
Blocks
shutdown()
or
close()
until data transfers have finished
or the given timeout [int] expired.
在数据传输完成或给定超时 [int] 到期之前,阻止 shutdown() 或 close() 。
oobinline
Places out-of-band data in the input data stream.
将带外数据放入输入数据流中。
priority=<priority>
Sets the protocol defined <priority> [<int>] for outgoing
packets.
为传出数据包设置协议定义的<priority> [<int>]。
rcvbuf=<bytes>
Sets the size of the receive buffer after the
socket()
call to
<bytes> [int]. With TCP
sockets, this value corresponds to the socket's maximal window size.
在 socket() 调用后设置接收缓冲区的大小为 [int]。对于 TCP 套接字,此值对应于套接字的最大窗口大小。
rcvbuf-late=<bytes>
Sets the size of the receive buffer when the socket is already
connected to <bytes> [int].
With TCP sockets, this value corresponds to the socket's
maximal window size.
设置套接字已连接到 <bytes> [int] 时的接收缓冲区大小。对于 TCP 套接字,此值对应于套接字的最大窗口大小。
so-rcvtimeo=<time>, rcvtimeo=<time>
Specifies the time [int] until
recv()
,
read()
etc. functions timeout when no data is received. Note that in the transfer
phase socat only calls these functions when
select()
has reported
that data is available. However this option is useful with DTLS addresses to
timeout during connection negotiation.
指定在未收到数据时, recv() 、 read() 等函数超时的时间 [int]。请注意,在传输阶段,socat 仅在 select() 报告数据可用时调用这些函数。但是,此选项在 DTLS 地址上用于在连接协商期间设置超时。
so-sndtimeo=<time>, sndtimeo=<time>
Like so-recvtimeo, but for
send
. Not usecase
known.
类似于 so-recvtimeo,但用于 send 。未知用例。
rcvlowat=<bytes>
Specifies the minimum number of received bytes [int] until
the socket layer will pass the buffered data to socat.
指定接收的字节数[ int]的最小数量,直到套接字层将缓冲数据传递给 socat。
reuseaddr[=[0|1]]
Allows other sockets to bind to an address even if parts of it (e.g. the
local port) are already in use by socat. 即使 socat 已经使用了地址的部分(例如本地端口),也允许其他套接字绑定到该地址。
With version 1.8.0, this socket option is set automatically for TCP LISTEN
addresses. If you prefer the system default (no related
setsockopt(...SO_REUSEADDR...) call at all), use form reuseaddr=. 从版本 1.8.0 开始,对于 TCP LISTEN 地址,此套接字选项将自动设置。如果您更喜欢系统默认值(根本没有相关的 setsockopt(...SO_REUSEADDR...) 调用),请使用形式 reuseaddr= 。
(example).
(示例).
sndbuf=<bytes>
Sets the size of the send buffer after the
socket()
call to
<bytes> [int].
在 socket() 调用后设置发送缓冲区的大小为 <字节> [整数].
sndbuf-late=<bytes>
Sets the size of the send buffer when the socket is connected to
<bytes> [int].
当套接字连接到 <字节> [整数] 时设置发送缓冲区的大小。
sndlowat=<bytes>
Specifies the minimum number of bytes in the send buffer until the socket
layer will send the data to <bytes> [int].
指定发送缓冲区中的最小字节数,直到套接字层将数据发送到 <bytes> [ int]。
pf=<string>
Forces the use of the specified IP version or protocol. <string> can be
something like "ip4" or "ip6". The resulting value is
used as first argument to the
socket()
or
socketpair()
calls.
This option affects address resolution and the required syntax of bind and
range options.
强制使用指定的 IP 版本或协议。 可以是类似 "ip4" 或 "ip6" 的内容。生成的值将作为 socket() 或 socketpair() 调用的第一个参数。此选项会影响地址解析以及 bind 和 range 选项的所需语法。
socktype=<type>
Sets the type of the socket, specified as second argument to the
socket()
or
socketpair()
calls, to <type>
[int]. Address resolution is not affected by this option.
Under Linux, 1 means stream oriented socket, 2 means datagram socket, 3
means raw socket, and 5 seqpacket (stream keeping packet boundaries).
Datagrams are useful when you want to keep packet boundaries.
将套接字的类型设置为 [ int],作为 socket() 或 socketpair() 调用的第二个参数。此选项不会影响地址解析。在 Linux 下,1 表示面向流的套接字,2 表示数据报套接字,3 表示原始套接字,5 表示 seqpacket(保持数据包边界的流)。当您想要保持数据包边界时,数据报非常有用。
protocol
Sets the protocol of the socket, specified as third argument to the
socket()
or
socketpair()
calls, to <protocol>
[int]. Address resolution is not affected by this option.
6 means TCP, 17 means UDP.
设置套接字的协议,作为第三个参数传递给 socket() 或 socketpair() 调用,设置为 [ int]。此选项不会影响地址解析。6 表示 TCP,17 表示 UDP。
reuseport
Set the
SO_REUSEPORT
socket option.
设置 SO_REUSEPORT 套接字选项。
so-timestamp
Sets the SO_TIMESTAMP socket option. This enables receiving and logging of
timestamp ancillary messages.
设置 SO_TIMESTAMP 套接字选项。这将启用接收和记录时间戳辅助消息。
setsockopt=<level>:<optname>:<optval>
Invokes setsockopt() for the socket with the given parameters. level
[int] is used as second argument to setsockopt() and
specifies the layer, e.g. SOL_TCP for TCP (6 on Linux), or SOL_SOCKET for
the socket layer (1 on Linux). optname [int] is the
third argument to setsockopt() and tells which socket option is to be
set. For the actual numbers you might have to look up the appropriate include
files of your system. For the 4th and 5th setsockopt() parameters,
value [dalan] specifies an arbitrary sequence of bytes
that are passed to the function per pointer, with the automatically derived
length parameter.
使用给定参数为套接字调用 setsockopt() 。第二个参数使用[int]作为 setsockopt() 的参数,并指定层,例如,对于 TCP(Linux 上的 6),或对于套接字层(Linux 上的 1)。[int]是 setsockopt() 的第三个参数,并告诉要设置哪个套接字选项。对于实际数字,您可能需要查找系统的适当包含文件。对于第 4 和第 5 个 setsockopt() 参数, value [dalan]指定通过指针传递给函数的任意字节序列,带有自动派生的长度参数。
setsockopt-int=<level>:<optname>:<optval>
Like setsockopt, but <optval> is a pointer to int [int]
类似于 setsockopt ,但是指向 int 的指针[int]
setsockopt-listen=<level>:<optname>:<optval>
Like setsockopt, but for listen type addresses it is applied to the
listening socket instead of the connected socket.
类似于 setsockopt ,但对于监听类型地址,它应用于监听套接字而不是连接的套接字。
setsockopt-string=<level>:<optname>:<optval>
Like setsockopt, but <optval> is a string.
This string is passed to the function with trailing null character, and the
length parameter is automatically derived from the data.
像 setsockopt 一样,但 是一个字符串。这个字符串带有尾随的空字符,并且长度参数会自动从数据中派生。
UNIX option group UNIX 选项组
These options apply to UNIX domain based addresses.
这些选项适用于基于 UNIX 域的地址。
Binds to a random path or random address (on abstract namespace sockets).
This is useful with datagram client addresses (SENDTO, or CLIENT)
that are opened in child processes forked off from a common
parent process where the child processes cannot have different bind options.
In the path
X
's get replaced with a random character sequence
similar to tempnam(3). When no argument is given socat takes a
default like
/tmp/fileXXXXXX
. 绑定到随机路径或随机地址(在抽象命名空间套接字上)。这对于在从共同父进程分叉出的子进程中打开的数据报客户端地址( SENDTO ,或 CLIENT )非常有用,其中子进程无法具有不同的绑定选项。在路径 X 中,'s 会被替换为类似于 tempnam(3)的随机字符序列。当没有给出参数时,socat 会采用默认值,类似于 /tmp/fileXXXXXX 。
unix-tightsocklen[=(0|1)]
On socket operations, pass a socket address length that does not include the
whole
struct sockaddr_un
record but (besides other components) only
the relevant part of the filename or abstract string. Default is 1.
在套接字操作中,传递一个套接字地址长度,不包括整个 struct sockaddr_un 记录,而只包括文件名或抽象字符串的相关部分(除其他组件外)。默认值为 1。
IP4 and IP6 option groups IP4 和 IP6 选项组
These options can be used with IPv4 and IPv6 based sockets.
这些选项可用于基于 IPv4 和 IPv6 的套接字。
tos=<tos>
Sets the TOS (type of service) field of outgoing packets to <tos>
[byte] (see RFC 791).
将传出数据包的 TOS(服务类型)字段设置为 <tos> [字节](请参阅 RFC 791)。
ttl=<ttl>
Sets the TTL (time to live) field of outgoing packets to <ttl>
[byte].
将传出数据包的 TTL(生存时间)字段设置为 <ttl> [字节]。
ip-options=<data>
Sets IP options like source routing. Must be given in binary form,
recommended format is a leading "x" followed by an even number of hex
digits. This option may be used multiple times, data are appended.
E.g., to connect to host 10.0.0.1 via some gateway using a loose source
route, use the gateway as address parameter and set a loose source route
using the option
ip-options=x8307040a000001
. 设置 IP 选项,如源路由。必须以二进制形式给出,推荐的格式是一个前导“x”后跟偶数个十六进制数字。此选项可以多次使用,数据将被追加。例如,要通过某个网关连接到主机 10.0.0.1 并使用宽松源路由,可以将网关用作地址参数,并使用选项 ip-options=x8307040a000001 设置宽松源路由。
IP options are defined in RFC 791. IP 选项在 RFC 791 中定义。
mtudiscover=<0|1|2>
Takes 0, 1, 2 to never, want, or always use path MTU discover on this
socket.
采用 0、1、2 分别表示在此套接字上从不、希望或始终使用路径 MTU 发现。
ip-pktinfo
Sets the IP_PKTINFO socket option. This enables receiving and logging of
ancillary messages containing destination address and interface (Linux)
(example).
设置 IP_PKTINFO 套接字选项。这将启用接收和记录包含目标地址和接口的辅助消息(Linux)(示例)。
ip-recverr
Sets the IP_RECVERR socket option. This enables receiving and logging of
ancillary messages containing detailed error information.
设置 IP_RECVERR 套接字选项。这将启用接收和记录包含详细错误信息的辅助消息。
ip-recvopts
Sets the IP_RECVOPTS socket option. This enables receiving and logging of IP
options ancillary messages (Linux, *BSD).
设置 IP_RECVOPTS 套接字选项。这将启用接收和记录 IP 选项辅助消息(Linux,*BSD)。
ip-recvtos
Sets the IP_RECVTOS socket option. This enables receiving and logging of TOS
(type of service) ancillary messages (Linux).
设置 IP_RECVTOS 套接字选项。这将启用接收和记录 TOS(服务类型)辅助消息(Linux)。
ip-recvttl
Sets the IP_RECVTTL socket option. This enables receiving and logging of TTL
(time to live) ancillary messages (Linux, *BSD).
设置 IP_RECVTTL 套接字选项。这将启用接收和记录 TTL(生存时间)辅助消息(Linux,*BSD)。
ip-recvdstaddr
Sets the IP_RECVDSTADDR socket option. This enables receiving and logging of
ancillary messages containing destination address (*BSD)
(example).
设置 IP_RECVDSTADDR 套接字选项。这将启用接收和记录包含目标地址的辅助消息(*BSD)(示例)。
ip-recvif
Sets the IP_RECVIF socket option. This enables receiving and logging of
interface ancillary messages (*BSD) (example).
设置 IP_RECVIF 套接字选项。这将启用接收和记录接口辅助消息(*BSD)(示例)。
Makes the socket member of the specified multicast group. This only works
for IPv4, see ipv6-join-group for the IPv6
variant. The option takes the IP address of the multicast group and info
about the desired network interface. The most common syntax is the first
one, while the others are only available on systems that provide
struct mreqn (Linux). 使套接字成为指定组播组的成员。这仅适用于 IPv4,请参阅 ipv6-join-group 以获取 IPv6 变体。该选项接受组播组的 IP 地址和有关所需网络接口的信息。最常见的语法是第一个,而其他语法仅适用于提供 struct mreqn (Linux)的系统。
The indices of active network interfaces can be shown using the utility
procan.
可以使用实用程序 procan 显示活动网络接口的索引。
Makes the socket member of the specified multicast group for the
specified source, i.e. only multicast traffic from this address is to be
delivered. This only works for IPv4, see
ipv6-join-source-group for the IPv6
variant. The option takes the IP address of the multicast group, the IP
address of the desired network interface and the source IP address of the
multicast traffic.
使套接字成为指定源的指定多播组的成员,即只传递来自此地址的多播流量。这仅适用于 IPv4,有关 IPv6 变体,请参阅 ipv6-join-source-group。该选项接受多播组的 IP 地址,所需网络接口的 IP 地址以及多播流量的源 IP 地址。
Makes the socket member of the specified multicast group. This only works
for IPv6, see ip-add-membership for the
IPv4 variant. The option takes the IP address of the multicast
group and info about the desired network interface.
The indices of active network interfaces can be shown using the utility
procan.
使套接字成为指定多播组的成员。这仅适用于 IPv6,有关 IPv4 变体,请参阅 ip-add-membership。该选项接受多播组的 IP 地址和有关所需网络接口的信息。可以使用实用程序 procan 显示活动网络接口的索引。
Makes the socket member of the specified multicast group for the
specified source, i.e. only multicast traffic from this address is to be
delivered. This only works for IPv6, see
ip-add-source-membership for the
IPv4 variant. The option takes the IP address of the multicast group,
info about the desired network interface and the source IP address of the
multicast traffic. The indices of active network interfaces can be shown
using the utility procan.
使套接字成为指定源的指定多播组的成员,即只传递来自此地址的多播流量。这仅适用于 IPv6,有关 IPv4 变体,请参阅 ip-add-source-membership。该选项接受多播组的 IP 地址,有关所需网络接口的信息以及多播流量的源 IP 地址。可以使用实用程序 procan 显示活动网络接口的索引。
ip-multicast-if=<hostname>
Specifies hostname or address of the network interface to be used for
multicast traffic.
指定用于多播流量的网络接口的主机名或地址。
ip-multicast-loop[=<bool>]
Specifies if outgoing multicast traffic should loop back to the interface.
指定是否应将出站多播流量回送到接口。
ip-multicast-ttl=<byte>
Sets the TTL used for outgoing multicast traffic. Default is 1.
设置用于出站多播流量的 TTL。默认值为 1。
ip-transparent
Sets the IP_TRANSPARENT socket option.
This option might require root privilege.
设置 IP_TRANSPARENT 套接字选项。此选项可能需要 root 权限。
Resolver options 解析器选项
These options temporarily change the behaviour of hostname resolution. The
options of form
ai-*
affect behaviour of the
getaddrinfo()
function that
includes
/etc/hosts
and NIS based lookups.
这些选项暂时更改主机名解析的行为。形式为 ai-* 的选项会影响包括 /etc/hosts 和基于 NIS 的查找在内的 getaddrinfo() 函数的行为。
The addresses of form
res-*
only affect DNS lookups, and only when the
result is not cached in
nscd
. These options might not work on all
operating systems or libc implementations.
仅当结果未缓存在 nscd 中时, res-* 表单的地址才会影响 DNS 查找。这些选项可能在所有操作系统或 libc 实现上都无法正常工作。
ai-addrconfig[=0|1]
addrconfig[=0|1]
Sets or unsets the AI_ADDRCONFIG flag to prevent name resolution to address
families that are not available on the computer (e.g. IPv6). Default value
is 1 in case the resolver does not get an address family hint from Socat
address or defaults.
设置或取消 AI_ADDRCONFIG 标志,以防止名称解析到计算机上不可用的地址族(例如 IPv6)。默认值为 1,以防解析器未从 Socat 地址或默认值获取地址族提示。
ai-passive[=0|1]
passive[=0|1]
Sets of unsets the AI_PASSIVE flag for
getaddrinfo()
calls.
Default is 1 for LISTEN, RECV, and RECVFROM type addresses, and with
bind option.
为 getaddrinfo() 调用设置或取消 AI_PASSIVE 标志。对于 LISTEN、RECV 和 RECVFROM 类型地址以及带有 bind 选项,默认值为 1。
ai-v4mapped[=0|1]
v4mapped[=0|1]
Sets or unsets the AI_V4MAPPED flag for
getaddrinfo()
. With socat
addresses requiring IPv6 addresses, this resolves IPv4 addresses to the
approriate IPv6 address [::ffff:*:*]. For IPv6 Socat addresses, the default
is 1.
设置或取消 getaddrinfo() 的 AI_V4MAPPED 标志。对于需要 IPv6 地址的 socat 地址,这将将 IPv4 地址解析为适当的 IPv6 地址 [::ffff:*:*]。对于 IPv6 Socat 地址,默认值为 1。
res-debug
res-aaonly
res-usevc
res-primary
res-igntc
res-recurse
res-defnames
res-stayopen
res-dnsrch
These options set the corresponding resolver (name resolution) option flags.
Append "=0" to clear a default option. See man resolver(5) for
more information on these options. Socat restores the old values after
finishing the open phase of the address, so these options are valid just for
the address they are applied to. 这些选项设置相应的解析器(名称解析)选项标志。附加“=0”以清除默认选项。有关这些选项的更多信息,请参阅 man resolver(5)。Socat 在地址的打开阶段完成后恢复旧值,因此这些选项仅对其应用的地址有效。
Please note that these flags only affect DNS resolution, but not hosts or
NIS based name resolution, and they have no effect when (g)libc retrieves
the results from
nscd
.
请注意,这些标志仅影响 DNS 解析,但不影响基于主机或 NIS 的名称解析,并且在 (g)libc 从 nscd 检索结果时不起作用。
res-retrans=<int>
Sets the retransmission time interval of the DNS resolver (based on an
undocumented feature).
设置 DNS 解析器的重传时间间隔(基于一个未记录的特性)。
res-retry=<int>
Sets the number of retransmits of the DNS resolver (based on an undocumented
feature).
设置 DNS 解析器的重传次数(基于一个未记录的特性)。
res-nsaddr=<ipaddr>[:<port>]
Tries to overwrite nameserver settings loaded from /etc/resolv.conf by
writing the given IPv4 address into the undocumented
_res:nsaddr_list[0]
field.
/etc/hosts
is still checked by resolver. Please note that glibc's
nscd
is always queried first when it is running!
尝试通过将给定的 IPv4 地址写入未记录的 _res:nsaddr_list[0] 字段,覆盖从 /etc/resolv.conf 加载的域名服务器设置。解析器仍会检查 /etc/hosts 。请注意,当 glibc 运行时,始终首先查询 glibc 的 nscd !
IP6 option group IP6 选项组
These options can only be used on IPv6 based sockets. See IP
options for options that can be applied to both IPv4 and IPv6
sockets.
这些选项只能用于基于 IPv6 的套接字。有关可应用于 IPv4 和 IPv6 套接字的选项,请参阅 IP 选项。
ipv6only[=<bool>]
Sets the IPV6_V6ONLY socket option. If 0, the TCP stack will also accept
connections using IPv4 protocol on the same port. The default is system
dependent.
设置 IPV6_V6ONLY 套接字选项。如果为 0,则 TCP 栈还将接受在相同端口上使用 IPv4 协议的连接。默认值取决于系统。
ipv6-recvdstopts
Sets the IPV6_RECVDSTOPTS socket option. This enables receiving and logging
of ancillary messages containing the destination options.
设置 IPV6_RECVDSTOPTS 套接字选项。这将启用接收和记录包含目标选项的辅助消息。
ipv6-recvhoplimit
Sets the IPV6_RECVHOPLIMIT socket option. This enables receiving and logging
of ancillary messages containing the hoplimit.
设置 IPV6_RECVHOPLIMIT 套接字选项。这将启用接收和记录包含跳数限制的辅助消息。
ipv6-recvhopopts
Sets the IPV6_RECVHOPOPTS socket option. This enables receiving and logging
of ancillary messages containing the hop options.
设置 IPV6_RECVHOPOPTS 套接字选项。这将启用接收和记录包含跳数选项的辅助消息。
ipv6-recvpktinfo
Sets the IPV6_RECVPKTINFO socket option. This enables receiving and logging
of ancillary messages containing destination address and interface.
设置 IPV6_RECVPKTINFO 套接字选项。这将启用接收和记录包含目标地址和接口的辅助消息。
ipv6-unicast-hops=link(TYPE_INT)(<int>)
Sets the IPV6_UNICAST_HOPS socket option. This sets the hop count limit
(TTL) for outgoing unicast packets.
设置 IPV6_UNICAST_HOPS 套接字选项。这为传出单播数据包设置了跳数限制(TTL)。
ipv6-recvrthdr
Sets the IPV6_RECVRTHDR socket option. This enables receiving and logging
of ancillary messages containing routing information.
设置 IPV6_RECVRTHDR 套接字选项。这将启用接收和记录包含路由信息的辅助消息。
ipv6-tclass
Sets the IPV6_TCLASS socket option. This sets the transfer class of outgoing
packets.
设置 IPV6_TCLASS 套接字选项。这将设置传出数据包的传输类。
ipv6-recvtclass
Sets the IPV6_RECVTCLASS socket option. This enables receiving and logging
of ancillary messages containing the transfer class.
设置 IPV6_RECVTCLASS 套接字选项。这将启用接收和记录包含传输类的辅助消息。
TCP option group TCP 选项组
These options may be applied to TCP sockets. They work by invoking
setsockopt()
with the appropriate parameters.
这些选项可以应用于 TCP 套接字。它们通过使用适当的参数调用 setsockopt() 来工作。
While listening, accepts connections only when data from the peer arrived.
在监听时,仅在来自对等方的数据到达时才接受连接。
keepcnt=<count>
Sets the number of keepalives before shutting down the socket to
<count> [int].
设置在关闭套接字之前保持的保持活动次数为 <count> [整数]。
keepidle=<seconds>
Sets the idle time before sending the first keepalive to <seconds>
[int].
设置在发送第一个保持活动之前的空闲时间为 <秒> [整数]。
keepintvl=<seconds>
Sets the interval between two keepalives to <seconds>
[int].
设置两个保持活动之间的间隔为 <秒> [整数]。
linger2=<seconds>
Sets the time to keep the socket in FIN-WAIT-2 state to <seconds>
[int].
将套接字保持在 FIN-WAIT-2 状态的时间设置为<秒> [int]。
mss=<bytes>
Sets the MSS (maximum segment size) after the
socket()
call to <bytes>
[int]. This
value is then proposed to the peer with the SYN or SYN/ACK packet
(example).
在 socket() 调用后将 MSS(最大分段大小)设置为<字节> [int]。然后将此值与 SYN 或 SYN/ACK 数据包一起提议给对等方(示例)。
mss-late=<bytes>
Sets the MSS of the socket after connection has been established to <bytes>
[int].
在建立连接后将套接字的 MSS 设置为<字节> [int]。
nodelay
Turns off the Nagle algorithm for measuring the RTT (round trip time).
关闭 Nagle 算法,用于测量往返时间(RTT)。
rfc1323
Enables RFC1323 TCP options: TCP window scale, round-trip time measurement
(RTTM), and protect against wrapped sequence numbers (PAWS) (AIX).
启用 RFC1323 TCP 选项:TCP 窗口缩放,往返时间测量(RTTM),并保护免受包装序列号(PAWS)的影响(AIX)。
Sets the maximal number of SYN retransmits during connect to <count>
[int].
设置在连接到 <count> [ int] 时 SYN 重传的最大次数。
md5sig
Enables generation of MD5 digests on the packets (FreeBSD).
启用在数据包上生成 MD5 摘要(FreeBSD)。
noopt
Disables use of TCP options (FreeBSD, MacOSX).
禁用 TCP 选项的使用(FreeBSD,MacOSX)。
nopush
sets the TCP_NOPUSH socket option (FreeBSD, MacOSX).
设置 TCP_NOPUSH 套接字选项(FreeBSD,MacOSX)。
sack-disable
Disables use the selective acknowledge feature (OpenBSD).
禁用使用选择性确认功能(OpenBSD)。
signature-enable
Enables generation of MD5 digests on the packets (OpenBSD).
启用在数据包上生成 MD5 摘要(OpenBSD)。
abort-threshold=<milliseconds>
Sets the time to wait for an answer of the peer on an established connection
(HP-UX).
设置在已建立连接时等待对等方答复的时间(HP-UX)。
conn-abort-threshold=<milliseconds>
Sets the time to wait for an answer of the server during the initial connect
(HP-UX).
设置在初始连接期间等待服务器答复的时间(HP-UX)。
keepinit
Sets the time to wait for an answer of the server during connect() before
giving up. Value in half seconds, default is 150 (75s) (Tru64).
在调用 connect()之前设置等待服务器答复的时间。值以半秒为单位,默认值为 150(75 秒)(Tru64)。
paws
Enables the "protect against wrapped sequence numbers" feature (Tru64).
启用“保护包装序列号”功能(Tru64)。
Enables the time stamp option that allows RTT recalculation on existing
connections (Tru64).
启用时间戳选项,允许在现有连接上重新计算 RTT(Tru64)。
UDP option group UDP 选项组
This option may be applied to UDP datagram sockets.
此选项可应用于 UDP 数据报套接字。
udp-ignore-peerport>
Address UDP-DATAGRAM expects incoming responses to come from the port
specified in its second parameter. With this option, it accepts packets
coming from any port.
地址 UDP-DATAGRAM 期望传入响应来自其第二个参数中指定的端口。使用此选项,它接受来自任何端口的数据包。
UDPLITE option group UDPLITE 选项组
These options may be applied to UDPLITE addresses: