socat(1) socat(1) (NAME) socat - (SOcket CAT) (SYNOPSIS) socat [options]
socat -V socat -h[h[h]] | -?[?[?]] filan procan (DESCRIPTION) Socat (byte stream) . ( ) socat . Filan (stdout) . socat . -h . Procan . UNIX socat . socat . init () (logging) . open ( ) socat . (blocking) socks . transfer () socat select() socat (newline) . EOF closing () . Socat EOF (shutdown) (graceful) . socat . (OPTIONS) Socat . (address options) . -V stdout . -h | -? stdout . -hh | -?? -h . . -hhh | -??? -hh . -d (fatal) (error) (warning) (notice) . (DIAGNOSTICS) . -d0 socat 1.7.4 . -d -d | -dd | -d2 . -d -d -d | -ddd | -d3 (info) . -d -d -d -d | -dddd | -d4 (debug) . -D . --experimental . -ly[] stderr syslog -d . syslog "daemon" . . -lf stderr [ ] . libwrap . -ls stderr ( ). libwrap syslog . -lp . -lu (timestamp) . syslog . -lm[] . stderr socat ( fork accept) syslog . syslog "daemon" . -lh (hostname) . HOSTNAME uname() . -v stderr . "> " "< " . -x stderr . "> " "< " . -v . -r () (dump) . $$ ( pid) $PROGNAME ( -lp ) $TIMESTAMP ( %Y%m%dT%H%M%S) MICROS ( ) . . -R () . -r . -b [size_t] . . 8192 . -s socat . socat . socat . -S socat . socat core dump . SIGHUP SIGINT SIGQUIT SIGILL SIGABRT SIGBUS SIGFPE SIGSEGV SIGTERM (0x89de ) ( SIGFPE 8 0x0080 ). : SIGHUP SIGINT SIGQUIT SIGUSR1 SIGPIPE SIGALRM SIGTERM SIGCHLD . -t EOF ( ignoreeof ) (shutdown) . socat [timeval] . EOF socat . 0.5 0 . ..IP "-T" : socat [timeval] ( ...) . 1.8.0.0 "0" "" 1.8.0.1 "0" 0 0> -1 . UDP EOF . -u . (). -U . . -g . socket . -L lockfile . lockfile lockfile (unlink) . -W lockfile . lockfile lockfile (unlink) . -4 IP 4 . 1.8.0.1 . -6 IP 6 . -0 IP (LISTEN RECV ..) ( BSD) . --statistics -S socat ( ) . USR1 . (ADDRESS SPECIFICATIONS) socat . ':' ',' . ( TCP4 OPEN EXEC). ('-' STDIO TCP TCP4). . : FD ( ) ':' ',' '/' GOPEN ( ) . . TCP4 ( ) ( ) . . . '=' . . . . ( -g). single () . "!!" dual () . socat . . / . -u -U . . 1.5.0 socat (escape) . ( { [ ' - ) } ] ' - . socat : , !! . \ "" . . CREATE: creat() . creat . -u -U . O_LARGEFILE . OPEN create,create . . (named pipe) creat() (block) . : FD,REG,NAMED : mode, mode, user, group, unlink-early, unlink-late, append : OPEN, GOPEN DCCP-CONNECT:: (DCCP::) DCCP [ IP] [ DCCP] pf IP . : FD,SOCKET,IP4,IP6,SCTP,CHILD,RETRY : bind, connect-timeout, tos, dccp-set-ccid, nonblock, sourceport, retry, readbytes : DCCP4-CONNECT, DCCP6-CONNECT, DCCP-LISTEN, TCP-CONNECT SCTP-CONNECT DCCP4-CONNECT:: (DCCP4::) DCCP-CONNECT IPv4 . : FD,SOCKET,IP4,DCCP,CHILD,RETRY DCCP6-CONNECT:: (DCCP6::) DCCP-CONNECT IPv6 . : FD,SOCKET,IP6,DCCP,CHILD,RETRY DCCP-LISTEN: (DCCP-L:) [ DCCP] DCCP . IP pf socat (-4, -6) SOCAT_DEFAULT_LISTEN_IP . . : FD,SOCKET,LISTEN,CHILD,RANGE,IP4,IP6,DCCP,RETRY : fork, bind, range, max-children, backlog, accept-timeout, dccp-set-sid, su, reuseaddr, retry : DCCP4-LISTEN, DCCP6-LISTEN, TCP-LISTEN, SCTP-LISTEN, DCCP-CONNECT DCCP4-LISTEN: (DCCP4-L:) DCCP-LISTEN IPv4 . : FD,SOCKET,LISTEN,CHILD,RANGE,IP4,DCCP,RETRY DCCP6-LISTEN: (DCCP6-L:) DCCP-LISTEN IPv6 . : FD,SOCKET,LISTEN,CHILD,RANGE,IP6,DCCP,RETRY EXEC: fork execvp() . . '/' '/' ARGV[0] . execvp() $PATH . socat stdin socketpair() stdout . () : FD,SOCKET,EXEC,FORK,TERMIOS : path, fdin, fdout, chroot, su, su-d, nofork, socktype, pty, stderr, ctty, setsid, pipes, umask, login, sigint, sigquit, netns : SYSTEM,SHELL FD: . UN*X . : FD (TERMIOS,REG,SOCKET) : STDIO, STDIN, STDOUT, STDERR GOPEN: (Generic open ) . . . socat socat sendto() . socat O_APPEND . O_CREAT (). : FD,REG,SOCKET,NAMED,OPEN : OPEN, CREATE, UNIX-CONNECT.IP IP-SENDTO:: IP . pf IP . [ IP] host . IP . : FD,SOCKET,IP4,IP6 : pf, ttl : IP4-SENDTO, IP6-SENDTO, IP-RECVFROM, IP-RECV, UDP-SENDTO, UNIX-SENDTO INTERFACE: . . Linux . : FD,SOCKET : pf, type : ip-recv IP4-SENDTO:: IP-SENDTO IPv4 . : FD,SOCKET,IP4 IP6-SENDTO:: IP-SENDTO IPv6 . : FD,SOCKET,IP6 IP-DATAGRAM:
: broadcast multicast . RANGE TCPWRAP . broadcast multicast . : FD, SOCKET, IP4, IP6, RANGE : 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 : IP4-DATAGRAM, IP6-DATAGRAM, IP-SENDTO, IP-RECVFROM, IP-RECV, UDP-DATAGRAM IP4-DATAGRAM:: IP-DATAGRAM IPv4 . () : FD,SOCKET,IP4,RANGE IP6-DATAGRAM:: IP-DATAGRAM IPv6 . IPv6 broadcast . : FD,SOCKET,IP6,RANGE IP-RECVFROM: IP . pf IP . . fork - - . UDP ntpd named . IP . IP-SENDTO ( ). IP . RECVFROM . : FD,SOCKET,IP4,IP6,CHILD,RANGE : pf, fork, range, ttl, broadcast : IP4-RECVFROM, IP6-RECVFROM, IP-SENDTO, IP-RECV, UDP-RECVFROM, UNIX-RECVFROM IP4-RECVFROM: IP-RECVFROM IPv4 . : FD,SOCKET,IP4,CHILD,RANGE IP6-RECVFROM: IP-RECVFROM IPv6 . : FD,SOCKET,IP6,CHILD,RANGE IP-RECV: IP . pf IP . . -u -U . IP-SENDTO socat . IP . : FD,SOCKET,IP4,IP6,RANGE : pf, range : IP4-RECV, IP6-RECV, IP-SENDTO, IP-RECVFROM, UDP-RECV, UNIX-RECV IP4-RECV: IP-RECV IPv4 . : FD,SOCKET,IP4,RANGE IP6-RECV: IP-RECV IPv6 . : FD,SOCKET,IP6,RANGE OPEN: open() (). UNIX . : . : FD,REG,NAMED,OPEN : creat, excl, noatime, nofollow, append, rdonly, wronly, lock, readbytes, ignoreeof : CREATE, GOPEN, UNIX-CONNECT.IP OPENSSL:: SSL [ TCP] [ IP] TCP/IP pf . : 1.7.2.4 cafile capath IP . 1.7.3.0 socat openssl-commonname . socat commonName (subject) DNS subjectAltName . (wildcard) . : FD,SOCKET,IP4,IP6,TCP,OPENSSL,RETRY : min-proto-version, cipher, verify, commonname, cafile, capath, certificate, key, compress, bind, pf, connect-timeout, sourceport, retry : OPENSSL-LISTEN, TCP OPENSSL-LISTEN: tcp [ TCP] . IP pf . SSL . : certificate . : cafile capath IP ! : FD,SOCKET,IP4,IP6,TCP,LISTEN,OPENSSL,CHILD,RANGE,RETRY : pf, min-proto-version, cipher, verify, commonname, cafile, capath, certificate, key, compress, fork, bind, range, tcpwrap, su, reuseaddr, retry : OPENSSL, TCP-LISTEN OPENSSL-DTLS-CLIENT:: DTLS [ UDP] [ IP] UDP/IP pf . Socat subjectAltName commonName openssl-commonname . (wildcard) . -b socat (overhead) . -T . : FD,SOCKET,IP4,IP6,OPENSSL,RETRY : min-proto-version, cipher, verify, commonname, cafile, capath, certificate, key, compress, bind, pf, sourceport, retry, rcvtimeo : OPENSSL-DTLS-SERVER, OPENSSL-CONNECT, UDP-CONNECT OPENSSL-DTLS-SERVER: UDP [ UDP] . IP pf . DTLS . : certificate . : cafile capath IP ! -b socat . -T . : FD,SOCKET,IP4,IP6,LISTEN,OPENSSL,CHILD,RANGE,RETRY : pf, min-proto-version, cipher, verify, commonname, cafile, capath, certificate, key, compress, fork, bind, range, tcpwrap, su, reuseaddr, retry rcvtimeo : OPENSSL-DTLS-CLIENT, OPENSSL-LISTEN, UDP-LISTEN PIPE: . . 1.4.3 socat ( unlink-close ). : (echo) . : socat ( 2.4: ) socat (block) . socat -b 2048 . : FD,NAMED,OPEN : rdonly, nonblock, group, user, mode, unlink-early : unnamed pipe.IP "PIPE" (pipe) . (echo) . : socat ( 2.4: ) socat (block) . -b 2048 . : FD : named pipe SOCKETPAIR SOCKETPAIR socketpair . . datagram (packet boundaries) . : FD : socktype : unnamed pipe STALL EOF . . TEXT: : . EXEC . stdout . : echo "" | socat STDIO TCP:: : socat TEXT:"\n" TCP:: . sudo . POSIXMQ-READ:/ POSIX () . . -u -U (dual addresses) . Socat POSIX MQ (filedescriptors) . : posixmq-priority, unlink-early, unlink-close, o-nonblock, o-creat, o-excl, umask POSIXMQ-RECEIVE:/ POSIXMQ-RECV:/ POSIX () . . POSIXMQ-READ . : POSIX MQ recv with fork : posixmq-priority, fork, max-children, unlink-early, unlink-close, o-creat, o-excl, umask POSIXMQ-SEND:/ POSIX () . . POSIXMQ-READ . () : posixmq-priority, posixmq-flush, fork, max-children, unlink-early, unlink-close, o-creat, o-excl, umask POSIXMQ-WRITE:/ POSIXMQ-SEND . POSIXMQ-BIDIRECTIONAL:/mqueue POSIXMQ:/mqueue POSIX (context) / () / . . POSIXMQ POSIXMQ-BIDIRECTIONAL . POSIXMQ-READ POSIXMQ-SEND . PROXY::: TCP/IP pf (HTTP proxy) CONNECT hostname:port . socat (). HTTP . : FD,SOCKET,IP4,IP6,TCP,HTTP,RETRY : proxyport, ignorecr, proxyauth, resolve, crnl, bind, connect-timeout, mss, sourceport, retry : SOCKS, TCP PTY (pty) master . slave (). ptmx openpty ptmx (POSIX). : FD,NAMED,PTY,TERMIOS : link, openpty, wait-slave, mode, user, group : UNIX-LISTEN, PIPE, EXEC, SYSTEM, SHELL READLINE GNU readline history stdio (). GNU readline history . stdio ( ) readline . : FD,READLINE,TERMIOS : history, noecho : STDIO SCTP-CONNECT:: SCTP [ IP] [ TCP] IP pf . : FD,SOCKET,IP4,IP6,SCTP,CHILD,RETRY : bind, pf, connect-timeout, tos, mtudiscover, mtudiscover6, sctp-maxseg, sctp-nodelay, nonblock, sourceport, retry, readbytes : SCTP4-CONNECT, SCTP6-CONNECT, SCTP-LISTEN, TCP-CONNECT.IP "SCTP4-CONNECT::" SCTP-CONNECT IPv4 . : FD,SOCKET,IP4,SCTP,CHILD,RETRY SCTP6-CONNECT:: SCTP-CONNECT IPv6 . : FD,SOCKET,IP6,SCTP,CHILD,RETRY SCTP-LISTEN: [ TCP] SCTP . IP 4 pf socat (-4 -6) SOCAT_DEFAULT_LISTEN_IP . . : FD,SOCKET,LISTEN,CHILD,RANGE,IP4,IP6,SCTP,RETRY : crnl, fork, bind, range, tcpwrap, pf, max-children, backlog, accept-timeout, sctp-maxseg, sctp-nodelay, su, reuseaddr, retry : SCTP4-LISTEN, SCTP6-LISTEN, TCP-LISTEN, SCTP-CONNECT SCTP4-LISTEN: SCTP-LISTEN IPv4 . : FD,SOCKET,LISTEN,CHILD,RANGE,IP4,SCTP,RETRY SCTP6-LISTEN: SCTP-LISTEN IPv6 . : FD,SOCKET,LISTEN,CHILD,RANGE,IP6,SCTP,RETRY SOCKET-CONNECT::: SOCK_STREAM ( socket(2) ) remote-address . int . . remote-address sockaddr sa_family ( BSD) sa_len . -g socat . : FD,SOCKET,CHILD,RETRY : bind, setsockopt, : TCP, UDP-CONNECT, UNIX-CONNECT, SOCKET-LISTEN, SOCKET-SENDTO SOCKET-DATAGRAM:::: ( socket(2) ) remote-address . int . . remote-address sockaddr sa_family ( BSD) sa_len . -g socat . : FD,SOCKET,RANGE : bind, range, setsockopt, : UDP-DATAGRAM, IP-DATAGRAM, SOCKET-SENDTO, SOCKET-RECV, SOCKET-RECVFROM SOCKET-LISTEN::: SOCK_STREAM ( socket(2) ) local-address . int . . local-address sockaddr sa_family ( BSD) sa_len . -g socat . : FD,SOCKET,LISTEN,RANGE,CHILD,RETRY : setsockopt, setsockopt-listen, : TCP, UDP-CONNECT, UNIX-CONNECT, SOCKET-LISTEN, SOCKET-SENDTO, SOCKET-SENDTO SOCKET-RECV:::: ( socket(2) ) . . int . . local-address sockaddr sa_family ( BSD) sa_len . : FD,SOCKET,RANGE : range, setsockopt, setsockopt-listen : UDP-RECV, IP-RECV, UNIX-RECV, SOCKET-DATAGRAM, SOCKET-SENDTO, SOCKET-RECVFROM SOCKET-RECVFROM:::: ( socket(2) ) . . int . . local-address sockaddr sa_family ( BSD) sa_len . RECVFROM . : FD,SOCKET,CHILD,RANGE : fork, range, setsockopt, setsockopt-listen : UDP-RECVFROM, IP-RECVFROM, UNIX-RECVFROM, SOCKET-DATAGRAM, SOCKET-SENDTO, SOCKET-RECV.IP "SOCKET-SENDTO::::" ( socket(2) ). . int . (include) . remote-address sockaddr sa_family ( BSD) sa_len . : FD,SOCKET : bind, setsockopt, setsockopt-listen : UDP-SENDTO, IP-SENDTO, UNIX-SENDTO, SOCKET-DATAGRAM, SOCKET-RECV SOCKET-RECVFROM ACCEPT-FD: ( fork) . systemd "inetd mode" . : (example) : FD, SOCKET, TCP, CHILD, RETRY : fork, range, sourceport, lowport, tcpwrap SOCKS4::: [ IP] [ IPv4] [ TCP] socks IP pf (example). : FD,SOCKET,IP4,IP6,TCP,SOCKS4,RETRY : socksuser, socksport, sourceport, pf, retry : SOCKS5, SOCKS4A, PROXY, TCP SOCKS4A::: SOCKS4 socks 4a socks . : FD,SOCKET,IP4,IP6,TCP,SOCKS4,RETRY SOCKS5-CONNECT:::: SOCKS5-CONNECT::: [ IP] [ IPv4] [ TCP] socks TCP . . : FD, SOCKET, IP4, IP6, TCP, CHILD, RETRY : socksport, socksuser, sockspass, sourceport, pf, retry : SOCKS5-LISTEN, SOCKS4, SOCKS4A, PROXY, TCP SOCKS5-LISTEN:::: SOCKS5-LISTEN::: socks TCP [ IP] [ TCP] <-listen-host> [ IPv4] . . : FD, SOCKET, IP4, IP6, TCP, CHILD, RETRY : sourceport, pf, retry : SOCKS5-CONNECT, STDERR . -u -U (dual addresses) . : FD (TERMIOS,REG,SOCKET) : FD STDIN . -u -U . : FD (TERMIOS,REG,SOCKET) : readbytes : FD STDIO . : FD (TERMIOS,REG,SOCKET) : readbytes : FD STDOUT . -u -U . : FD (TERMIOS,REG,SOCKET) : FD SHELL: SHELL (fork) ($SHELL) . [] ',' "!!" ':' (escape) . socat stdin stdout . . : FD,SOCKET,EXEC,FORK,TERMIOS : path, fdin, fdout, chroot, su, su-d, nofork, socktype, pty, stderr, ctty, setsid, pipes, umask, sigint, sigquit : EXEC, SYSTEM.IP "SYSTEM:" (fork) system() . [] ',' "!!" (meta characters) (escape) . socat stdin stdout . : FD,SOCKET,EXEC,FORK,TERMIOS : path, fdin, fdout, chroot, su, su-d, nofork, socktype, pty, stderr, ctty, setsid, pipes, umask, sigint, sigquit, netns : EXEC, SHELL TCP:: [ TCP] [ IP] TCP/IP pf . : FD,SOCKET,IP4,IP6,TCP,RETRY : connect-timeout, retry, sourceport, netns, crnl, bind, pf, tos, mtudiscover, mtudiscover6, mss, nodelay, nonblock, readbytes : TCP4, TCP6, TCP-LISTEN, UDP, SCTP-CONNECT, UNIX-CONNECT TCP4:: TCP IPv4 (). : FD,SOCKET,IP4,TCP,RETRY TCP6:: TCP IPv6 . : FD,SOCKET,IP6,TCP,RETRY TCP-LISTEN: [ TCP] TCP/IP . IP pf socat (-4, -6) SOCAT_DEFAULT_LISTEN_IP . (block) . : FD,SOCKET,LISTEN,CHILD,RANGE,IP4,IP6,TCP,RETRY : crnl, fork, bind, range, tcpwrap, pf, max-children, backlog, accept-timeout, mss, su, reuseaddr, retry, cool-write : TCP4-LISTEN, TCP6-LISTEN, UDP-LISTEN, SCTP-LISTEN, UNIX-LISTEN, OPENSSL-LISTEN, TCP-CONNECT TCP4-LISTEN: TCP-LISTEN IPv4 (). : FD,SOCKET,LISTEN,CHILD,RANGE,IP4,TCP,RETRY TCP6-LISTEN: TCP-LISTEN IPv6 . : ipv6only : FD,SOCKET,LISTEN,CHILD,RANGE,IP6,TCP,RETRY TUN[:/] TUN/TAP netmask . socat << >> ("wire side") . /dev/net/tun ioctl()s . iff-up ! : << >> socat UDP TCP nodelay . : FD,NAMED,OPEN,TUN : iff-up, tun-device, tun-name, tun-type, interface-mtu, iff-no-pi, netns : ip-recv UDP:: [ UDP] [ IP] UDP/IP pf . UDP <<>> (end-of-file) . 1.8.1.0 UDP EOF ( shut-null). shut-none . : FD,SOCKET,IP4,IP6 : ttl, tos, bind, sourceport, pf : UDP4, UDP6, UDP-LISTEN, TCP, IP.IP "UDP4::" UDP IPv4 . : FD,SOCKET,IP4 UDP6:: UDP IPv6 . : FD,SOCKET,IP6 UDP-DATAGRAM:
: broadcast multicast . sourceport ( 1.7.4.0 Socat ) RANGE TCPWRAP . broadcast multicast . : FD,SOCKET,IP4,IP6,RANGE : 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 : UDP4-DATAGRAM, UDP6-DATAGRAM, UDP-SENDTO, UDP-RECVFROM, UDP-RECV, UDP-CONNECT, UDP-LISTEN, IP-DATAGRAM UDP4-DATAGRAM:
: UDP-DATAGRAM IPv4 (example1 example2). : FD,SOCKET,IP4, RANGE UDP6-DATAGRAM:
: UDP-DATAGRAM IPv6 . : FD,SOCKET,IP6,RANGE UDP-LISTEN: UDP/IP [ UDP] `connects' . IP 4 pf . UDP . (EOF) UDP . 1.8.1.0 UDP EOF ( shut-null). shut-none . : FD,SOCKET,LISTEN,CHILD,RANGE,IP4,IP6 : fork, bind, range, pf : UDP, UDP4-LISTEN, UDP6-LISTEN, TCP-LISTEN UDP4-LISTEN: UDP-LISTEN IPv4 . : FD,SOCKET,LISTEN,CHILD,RANGE,IP4 UDP6-LISTEN: UDP-LISTEN IPv6 . : FD,SOCKET,LISTEN,CHILD,RANGE,IP6 UDP-SENDTO:: [ UDP] [ IP] UDP/IP 4 6 pf . . . UDP-RECVFROM UDP-RECV socat . UDP-DATAGRAM . : FD,SOCKET,IP4,IP6 : ttl, tos, bind, sourceport, pf : UDP4-SENDTO, UDP6-SENDTO, UDP-RECVFROM, UDP-RECV, UDP-CONNECT, UDP-LISTEN, IP-SENDTO UDP4-SENDTO:: UDP-SENDTO IPv4 . : FD,SOCKET,IP4 UDP6-SENDTO:: UDP-SENDTO IPv6 . : FD,SOCKET,IP6 UDP-RECVFROM: UDP [ UDP] UDP/IP 4 6 pf . . fork - - . UDP ntpd named . UDP-SENDTO socat . : . retry forever . UDP-DATAGRAM . : FD,SOCKET,IP4,IP6,CHILD,RANGE : fork, ttl, tos, bind, sourceport, pf : UDP4-RECVFROM, UDP6-RECVFROM, UDP-SENDTO, UDP-RECV, UDP-CONNECT, UDP-LISTEN, IP-RECVFROM, UNIX-RECVFROM UDP4-RECVFROM: UDP-RECVFROM IPv4 . : FD,SOCKET,IP4,CHILD,RANGE UDP6-RECVFROM: UDP-RECVFROM IPv6 . : FD,SOCKET,IP6,CHILD,RANGE.IP UDP-RECV: UDP [ UDP] UDP/IP pf . . . UDP-SENDTO socat syslog . -u -U (dual addresses) . : fork UDP-RECVFROM ( -u) . : FD,SOCKET,IP4,IP6,RANGE : pf, bind, sourceport, ttl, tos : UDP4-RECV, UDP6-RECV, UDP-SENDTO, UDP-RECVFROM, UDP-CONNECT, UDP-LISTEN, IP-RECV, UNIX-RECV UDP4-RECV: UDP-RECV IPv4 . : FD,SOCKET,IP4,RANGE UDP6-RECV: UDP-RECV IPv6 . : FD,SOCKET,IP6,RANGE UDPLITE-CONNECT:: UDPLITE4-CONNECT:: UDPLITE6-CONNECT:: UDPLITE-DATAGRAM:
: UDPLITE4-DATAGRAM:
: UDPLITE6-DATAGRAM:
: UDPLITE-LISTEN: UDPLITE4-LISTEN: UDPLITE6-LISTEN: UDPLITE-SENDTO:: UDPLITE4-SENDTO:: UDPLITE6-SENDTO:: UDPLITE-RECVFROM: UDPLITE4-RECVFROM: UDPLITE6-RECVFROM: UDPLITE-RECV: UDPLITE4-RECV: UDPLITE6-RECV: UDPLITE UDP UDP-Lite UDPLITE . UNIX-CONNECT: (UNIX domain socket) . . : FD,SOCKET,NAMED,RETRY,UNIX ) : bind : UNIX-LISTEN, UNIX-SENDTO, TCP UNIX-LISTEN: (UNIX domain stream socket) . . (bind) ( unlink-early !). . 1.4.3 socat ( unlink-close ) (). : FD,SOCKET,NAMED,LISTEN,CHILD,RETRY,UNIX : fork, umask, mode, user, group, unlink-early : UNIX-CONNECT, UNIX-RECVFROM, UNIX-RECV, TCP-LISTEN UNIX-SENDTO: [] . . (bind) ( /tmp/sock1 ). socat UNIX-RECVFROM UNIX-RECV . : FD,SOCKET,NAMED,UNIX : bind : UNIX-RECVFROM, UNIX-RECV, UNIX-CONNECT, UDP-SENDTO, IP-SENDTO UNIX-RECVFROM: [] . . fork - - . UNIX-SENDTO socat . : FD,SOCKET,NAMED,CHILD,UNIX RECVFROM . : fork umask : UNIX-SENDTO, UNIX-RECV, UNIX-LISTEN, UDP-RECVFROM, IP-RECVFROM UNIX-RECV: [] . . -u -U . UNIX-SENDTO socat . syslog . : FD,SOCKET,NAMED,UNIX : umask : UNIX-SENDTO, UNIX-RECVFROM, UNIX-LISTEN, UDP-RECV, IP-RECV UNIX-CLIENT: [] . . : FD,SOCKET,NAMED,UNIX : bind : UNIX-CONNECT, UNIX-SENDTO, GOPEN.IP VSOCK-CONNECT:: (stream) VSOCK [ VSOCK cid] [ VSOCK] . : FD,SOCKET,CHILD,RETRY : bind, connect-timeout, retry, readbytes : VSOCK-LISTEN, VSOCK-LISTEN: [ VSOCK] VSOCK . . : FD,SOCKET,LISTEN,CHILD,RETRY : fork, bind, max-children, backlog, su, reuseaddr, retry : VSOCK-CONNECT ABSTRACT-CONNECT: ABSTRACT-LISTEN: ABSTRACT-SENDTO: ABSTRACT-RECVFROM: ABSTRACT-RECV: ABSTRACT-CLIENT: ABSTRACT UNIX UNIX . "\0" . () Linux . UNIX ABSTRACT NAMED . : netns (ADDRESS OPTIONS) . . . . ( -g ). . "=value" value . sync O_SYNC open() . "ttl=value" setsockopt(fd, SOL_IP, IP_TTL, value, sizeof(int)) . socat "crnl" . su-d ( substuser-delayed) chroot() . () . socat . ( unlink unlink-early unlink-late) . . setsockopt() . open() . . Socat libc . . . xio.help . FD UN*X . socat . : fd . . ( fd) . cloexec[=] FD_CLOEXEC fcntl() . exec() . Socat fd . setlk[=] fcntl(fd, F_SETLK, ...) (discretionary) . . Linux "S" (g-x,g+s) "mand" (mandatory) . setlkw[=] fcntl(fd, F_SETLKW, ...) . . setlk . setlk-rd[=] fcntl(fd, F_SETLK, ...) . . setlk . setlkw-rd[=] fcntl(fd, F_SETLKW, ...) . . setlk . flock-ex[=] flock(fd, LOCK_EX) (advisory) . Socat () . flock-ex-nb[=] flock(fd, LOCK_EX|LOCK_NB) . ..IP "flock-sh[=]" flock(fd, LOCK_SH) . Socat . flock-sh-nb[=] flock(fd, LOCK_SH|LOCK_NB) . . lock[=] . setlk flock . POSIX (setlkw) . user= () . NAMED socat (bind) UNIX chown() ( !). socat fchown() . (root) . user-late= fd fchown() . . group= . NAMED socat (bind) UNIX chown() ( !). socat fchown() . (root) . group-late= fd fchown() . . mode= [ mode_t] ( ) . NAMED open() creat() . NAMED socat (bind) UNIX chmod() ( !). socat fchmod() . . : umask . umask . perm-late= fd fchmod() [ mode_t] . . append[=] . OPEN socat O_APPEND open() (). socat fcntl(fd, F_SETFL, O_APPEND) . nonblock[=] . connect() TCP (named pipe) . OPEN socat O_NONBLOCK open() . socat fcntl(fd, F_SETFL, O_NONBLOCK) . binary[=] (Cygwin). text[=] (Cygwin). noinherit[=] (spawned) (Cygwin). cool-write[=] EPIPE ECONNRESET error notice . socat . fork socat 0 . children-shutup . end-close[=] ( ) . (). shutdown(2) . close(2) "" . EXEC SYSTEM socat (kill ). . shut-none[=] ( ) . shut-down[=] ( ) shutdown(fd, SHUT_WR) . . shut-close[=] ( ) close(fd) . shut-null[=] EOF socat EOF . UDP . netcat socat null-eof . null-eof[=] socat ( ) . socat EOF ( shut-null ). ioctl-void= ioctl() request NULL . ioctl socat . ioctl-int=: ioctl() request . ioctl-intp=: ioctl() request . ioctl-bin=: ioctl() request . . ioctl-string=: ioctl() request . . NAMED.PP . UNIX bind / (target/peer). user group mode . user-early= () chown() . (root) . group-early= chown() . . perm-early= [ mode_t] chmod() . . unlink-early[=] user-early (unlink) . unlink[=] user-early (unlink) . unlink-late[=] (unlink) (race condition) . unlink-close[=] . (named pipes) UNIX pty (1) (0) . 1 0 . 1 . OPEN OPEN open() . `creat' O_CREAT . open() ( STDIO) fcntl(..., F_SETFL, ...) . append nonblock . creat[=] (). dsync[=] write() (metainfo) . excl[=] creat . largefile[=] 2^31 . noatime[=] O_NOATIME . noctty[=] . nofollow[=] . nshare[=] . rshare[=] . rsync[=] write() . sync[=] write() . rdonly[=] . wronly[=] . trunc[=] (truncate ). REG BLK UN*X (random access) . seek= lseek(fd, , SEEK_SET) ( lseek64 ) [ off_t off64_t] . . seek-cur= lseek(fd, , SEEK_CUR) ( lseek64 ) [ off_t off64_t] ( ) . . seek-end= lseek(fd, , SEEK_END) ( lseek64 ) [ off_t off64_t] . . ftruncate= ftruncate(fd, ) ( ftruncate64 ) [ off_t off64_t] . . secrm[=] unrm[=] compr[=] fs-sync[=] immutable[=] fs-append[=] nodump[=] fs-noatime[=] journal-data[=] notail[=] dirsync[=] ext2fs xfs reiserfs. man 1 chattr . (race condition) . PIPE (pipes / fifos) . f-setpipe-sz= setpipe= . . write() . .PP . . chdir= cd= . (master) . . umask= umask [ mode_t] . . (octal) '0' . umask . : umask : umask=0026 0640 . PROCESS . EXEC SYSTEM LISTEN CONNECT fork socat . chroot= chroot() (). (root) . chroot-early= chroot() . (root) . setgid= () . (root) . . setgid-early= setgid . setuid= ( ) . (root) . . su . setuid-early= setuid . su= ( ) (). (root) . su-d= substuser-delayed. ( ) (). chroot() . (root) . setpgid= . 0 1 . setsid (session) (). netns= (network namespace) . ( TCP ). (root) . READLINE readline . history= / (). noprompt 1.4.0 socat (prompt) readline . socat readline . noecho= . (newline) readline . "^[Pp]assword:.*$" "([Uu]ser:|[Pp]assword:)". regex(7) . () prompt= (prompt) readline . readline . socat . APPLICATION . ("raw") socat PROXY . cr / NL ('\n' 0x0a) / CR ('\r' 0x0d) . crnl / NL ('\n' 0x0a) / CRNL ("\r\n" 0x0d0a) (). : socat CR . ignoreeof EOF socat ( "tail -f") (). readbytes= socat ( EOF ). 0 . lockfile= lockfile . lockfile lockfile (unlink) . waitlock= lockfile . lockfile lockfile (unlink) . escape= EOF . (raw mode) (). SOCKET IP UNIX . setsockopt() . bind= bind() (bind) . : IP4 IP6 [hostname|hostaddress][:(service|port)] () VSOCK [cid][:(port)] . : unix-bind-tempname connect-timeout= [ timeval] . so-bindtodevice= . (root) . broadcast ( ) . debug (debugging) . dontroute () . keepalive (keepalive) . linger= shutdown() close() [ int] ( )..IP "oobinline" (out-of-band) . priority= [] . rcvbuf= socket() [int] . TCP (window size) . rcvbuf-late= [int] . TCP . so-rcvtimeo=