Socat & Co.

Aus TippvomTibb
Zur Navigation springen Zur Suche springen

Erfahrungen mit socat, nc (netcat) und ser2net. Motivation fuer diese Zusammenstellung war die Notwendigkeit Sensoren, bzw. Devices (TUL (EIB/KNX), Buderus Logamatic, Schmidt Holzofensteuerung, Wagner Sungo Solarthermie, ELV Wetterstation, Hörmann SupraMatic Garagentorantrieb, Tuercommander (Eigenbau), ELV Keymatic, Abus, und, und, und) an FHEM anzuschlieszen. Die Kabelage im Haus hatte ueberhand genommen und da meine CISCO-Switches noch einige Ports frei hatten waren schnell ein paar Atoms, PIs und Arduinos angschlossen. Um jetzt aber die Peripherie der Satelliten an FHEM anzuheften mussten die meist seriellen Adapter irgendwie dem Server mit FHEM zugänglich gemacht werden. Die o.g. drei Programme erfüllen bisher genau meine Vorstellungen. Leider konnte fhem2fhem mich nicht überzeugen. Die Baustelle FHEM auf dem zentralen Hausserver ist nach wie vor groß genug;-)

Die Inbetriebnahme der socat/nc/ser2net-Scripte dauerte nur einen Tag. Probleme macht noch die Stabilitaet. Der Stresstest für das (Gesamt-)System ist auch noch nicht ausgearbeitet.

Derzeitiger Einsatz von Socat und nc (netcat): Auf meinen Server läuft fhem. Fhem auf dem Interfacerechner oder Fritzbox oder Raspi oder .. laufen zu lassen ist für mich keine Option. Es sprechen einige Dinge wie Performance, zentrale Datenhaltung, Administrationaufwand dagegen. Auf dem Interface-Rechner fhem-gw (IP 192.168.178.XX) laufen derzeit 3 Interfaces + die Tuerklingel. Die 3 Interfaces werden über nc dem Server übergeben. Auf dem IPC läuft nc im Server-Modus auf Port 3333. (nc -lk 3333 & oder nc -lk 3333 | /bin/bash &) So ist es dann möglich die Klingel von jedem Rechner aus dem Netzwerk mit folgendem Kommando zu starten:

/usr/bin/netcat 192.168.178.12 3333 < /opt/fhem_resources/tuerklingel.cmd >result.txt. 

In tuerklingel.cmd steht aplay /fhem_resources/Assembly.wav. Da alles was in tuerklingel.cmd steht in der bash auf dem IPC ausgeführt wird, besteht hier natuerlich ein Sicherheitsrisiko, welches noch Beachtung finden sollte.

Zum Weiterreichen der 3 Interfaces wird ser2net benutzt: Auf Port 2001 in die Buderus Logamatic angebunden, 2002 der TPUART für den EIB, auf 2003 der CUL für die 868 MHz Kommunikation und auf 2004 ein FH1000PC ebenfalls für 868 MHz Kommunkation. Das FHZ1000PC-Funkinterface wird eigentlich nicht mehr benötigt. Werde ich wohl demnächst mal auf 433MHz umbauen um vielleicht die Schaltsteckdosen zu bedienen. Die Konfigurationsdatei ist /etc/ser2net.conf.

Jedes Kapitel beginnt jeweils mit der Eroerterung der Manpage. Im Anschluss folgen meine eigenen ausdokumentierten Konfigurationsdateien als Beispiele.

Was ich mal noch probieren muss:

- PuTTY starten (IP, Port bzw. raw als Verbindung angeben)
- auf der seriellen Schnittstelle ein beliebiges Terminalprogramm starten


Links

Tibbo

[1]

[2]

socat

Was sagt die Man-Page (man socat der Version 1.7.3.1):

NAME

     socat - Multipurpose relay (SOcket CAT)

Also auf deutsch ein "Vielzweck-Relais", oder besser vielleicht eine Allzweck-Übermittlungsstation. Der Sinn erschließt sich im Deutschen aus der Beschreibung allerdings immer noch nicht vollständig.

Socat ist ein Portmanteau (Kontamination) aus SOcket und CAT. Die beiden Ursprungsworte sind dem geübten Unixer wohl bekannt. Hier eine (Wiki-)Kurzdefinition.

Socket Ein Socket (von engl. Sockel, Steckverbindung oder Steckdose) ist ein vom Betriebssystem bereitgestelltes Objekt, das als Kommunikationsendpunkt dient. Ein Programm verwendet Sockets, um Daten mit anderen Programmen auszutauschen. Das andere Programm kann sich dabei auf demselben Computer (Interprozesskommunikation) oder einem anderen, via Netzwerk erreichbaren Computer befinden. Die Kommunikation über Sockets erfolgt in der Regel bidirektional, das heißt, über das Socket können Daten sowohl empfangen als auch gesendet werden.

cat cat ist einer der am meisten genutzten Befehle auf Unix-ähnlichen Betriebssystemen. Er hat im Wesentlichen drei Aufgaben in Bezug zu Textdateien: sie anzuzeigen, sie zu kombinieren oder neue zu erzeugen.

Betrachtet man sich nun die socat-Syntax entwickelt man langsam eine Vorstellung wozu socat dienlich sein kann.

SYNOPSIS

(Zusammenfassung)

      socat [options] <address> <address>
      socat -V
      socat -h[h[h]] | -?[?[?]]
      filan
      procan

Abgesehen von der Tatsache, dass in der ersten der fünf Zeilen das Wichtigste zum richtigen Gebrauch beschrieben steht, erkennt man, dass zu dem socat-Softwarepaket noch zwei weitere Programme, filan und procan, gehören. Auf diese wird weiter unten noch eingegangen.

Das linuxUSER-Magazin beschreibt socat in der Ausgabe 04.2014 wie folgt:

Socket Cat oder kurz Socat ermöglicht das Einrichten bidirektionaler Verbindungen zwischen zwei Systemen. Dabei reicht das Spektrum von der einfachen Datenübertragung bis hin zum Streamen großer Datenmengen. So eignet sich das Tool beispielsweise für schlichte TCP-Weiterleitungen ebenso wie als Relaying-Lösung zwischen IPv6 und IPv4. Auch als SSL-Wrapper auf Server- oder Client-Seite kommt Socat infrage, wenn der umzuleitende Dienst nicht SSL-fähigist. In Kombination mit Chroot lassen sich so sichere Umgebungen gestalten. Sowohl die umfangreiche Manpage als auch die Webseite des Projekts bieten dafür inspirierende Beispiele. 
Der Verbindungsaufbauerfolgt bei Socat in vier Stufen, beginnend mit dem Auswertender übergebenen Kommandozeilenparameter. Es folgt der Verbindungsaufbau,dessen erfolgreichen Abschluss Socat abwartet. Dann fährt es mit der Verarbeitung fort. Steht die Verbindung, lassen sich Daten in beide Richtungen übertragen.Sobald eines der Systeme ein EOFSignal sendet, baut Socat die Verbindung ab. Die gesamte Konfiguration erfolgt über Parameter,eine Konfigurationsdatei kennt das Tool nicht.Da es neben den Verbindungsoptionen zahlreiche weitere Einstellungen unterstützt,wie etwa Blöckgröße,Timeout oder Debugging,empfiehlt es sich, Socat via Skript aufzurufen.

Ab der Reihe nach.

DESCRIPTION

(noch ins Deutsche zu übersetzen)

      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.
      Filan  is  a  utility that prints information about its active file descriptors to stdout. It has been written for debugging socat, but might be
      useful for other purposes too. Use the -h option to find more infos.
      Procan is a utility that prints information about process parameters to stdout. It has been written to better understand some UNIX process prop-
      erties and for debugging socat, but might be useful for other purposes too.
      The life cycle of a socat instance typically consists of four phases:
      - In the 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.
      - 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.
      - 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.

OPTIONS

Die Nennung der (speziellen) Optionen -V, -h[h[h]] und -?[?[?]] (s.o.) ist nur dadurch begründet, dass diese ohne die oblogatorischen Adressbezeichner auskommen. Kleiner Hinweis am Rande: Angaben in [] sind optional also wahlfrei/nicht zwingend und Angaben in <> sind obligatorisch also verpflichtend/zwingend. Leider konnte ich keine entsprechende Erläuterung auf der Wiki-Seite finden.

  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 stellt einige (24) Kommandozeilenoptionen bereit, die das Verhalten des Programms beeinflussen. Diese haben nichts mit den (sogenannten) Adressoptionen zu tun, die weiter unten bei den Adressangaben erläutert werden. Aus Gründen der besseren Übersicht sind Mehrfachnennungen der Optionen -h oder -? und -d jeweils in einer Zeile zusammengefasst.

Nr Option Originaltext Übersetzung/Erläuterung Beispiele zu jeder Option finden sich im Anschluss an die Tabelle
1 -V Print version and available feature information to stdout, and exit. Gibt die Versionsnummer und eine Übersicht über die (einkompilierten) Möglichkeiten auf die Standardausgabe (idR der Bildschirm) aus und endet.
2 -h[h[h]] bzw. -?[?[?]] Print a help text to stdout describing command line options and available address types, and exit. (2x) 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. (3x) Like −hh, plus a list of all available address option names. Gibt den Hilfetext des Programms aus. Das Mehrfachnenen der Option erweiter den Hilfetext noch um mögliche Kurznamen und mögliche Adressoptionen.
3 -d[d[d[d]]] Without this option, only fatal and error messages are generated; applying this option also prints warning messages. See DIAGNOSTICS for more information. (2x) Prints fatal, error, warning, and notice messages. (3x) Prints fatal, error, warning, notice, and info messages. (4x) Prints fatal, error, warning, notice, info, and debug messages.
4 -D Logs information about file descriptors before starting the transfer phase.
5 −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.
6 −lf <logfile> Writes messages to <logfile> [filename] instead of stderr. Some third party libraries, in particular libwrap, might not obey this option.
7 -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.
8 −lp<progname> Overrides the program name printed in error messages and used for constructing environment variable names.
9 -lu Extends the timestamp of error messages to microsecond resolution. Does not work when logging to syslog.
10 −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".
11 −lh Adds hostname to log messages. Uses the value from environment variable HOSTNAME or the value retrieved with uname() if HOSTNAME is not set.
12 −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.
13 -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 .
14 −b<size> Sets the data transfer block <size> [size_t]. At most <size> bytes are transferred per step. Default is 8192 bytes.
15 -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.
16 −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.
17 −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.
18 -u Uses unidirectional mode. The first address is only used for reading, and the second address is only used for writing (example).
19 -U Uses unidirectional mode in reverse direction. The first address is only used for writing, and the second address is only used for reading.
20 -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.
21 −L<lockfile> If lockfile exists, exits with error. If lockfile does not exist, creates it and continues, unlinks lockfile on exit.
22 −W<lockfile> If lockfile exists, waits until it disappears. When lockfile does not exist, creates it and continues, unlinks lockfile on exit.
23 −4 Use IP version 4 in case that the addresses do not implicitly or explicitly specify a version; this is the default.
24 −6 Use IP version 6 in case that the addresses do not implicitly or explicitly specify a version.

ADDRESS SPECIFICATIONS

  With the address command line arguments, the user gives socat
  instructions and the necessary information for establishing the byte
  streams.
  An address specification usually consists of an address type keyword,
  zero or more required address parameters separated by ’:’ from the
  keyword and from each other, and zero or more address options separated
  by ’,’.
  The keyword specifies the address type (e.g., TCP4, OPEN, EXEC). For
  some keywords there exist synonyms (’−’ for STDIO, TCP for TCP4).
  Keywords are case insensitive. For a few special address types, the
  keyword may be omitted: Address specifications starting with a number
  are assumed to be FD (raw file descriptor) addresses; if a ’/’ is found
  before the first ’:’ or ’,’, GOPEN (generic file open) is assumed.
  The required number and type of address parameters depend on the
  address type. E.g., TCP4 requires a server specification (name or
  address), and a port specification (number or service name).
  Zero or more address options may be given with each address. They
  influence the address in some ways. Options consist of an option
  keyword or an option keyword and a value, separated by ’=’. Option
  keywords are case insensitive. For filtering the options that are
  useful with an address type, each option is member of one option group.
  For each address type there is a set of option groups allowed. Only
  options belonging to one of these address groups may be used (except
  with option −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.
  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.
  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 ""

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 address type requires write−only context, because a file opened
  with creat cannot be read from.
  Flags like O_LARGEFILE cannot be applied. If you need them use OPEN
  with options create,create.
  <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.
  Option groups: FD,REG,NAMED
  Useful options: mode, user, group, unlink−early, unlink−late, append
  See also: OPEN, GOPEN
  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)
  Option groups: FD,SOCKET,EXEC,FORK,TERMIOS
  Useful options: path, fdin, fdout, chroot, su, su−d, nofork, pty,
  stderr, ctty, setsid, pipes, login, sigint, sigquit
  See also: SYSTEM
  FD:<fdnum>
  Uses the file descriptor <fdnum>. It must already exist as valid UN*X
  file descriptor.
  Option groups: FD (TERMIOS,REG,SOCKET)
  See also: 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).
  Option groups: FD,REG,SOCKET,NAMED,OPEN
  See also: 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.
  Option groups: FD,SOCKET,IP4,IP6
  Useful options: pf, ttl
  See also: 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. Option groups: FD,SOCKET
  Useful options: pf, type
  See also: ip−recv
  IP4−SENDTO:<host>:<protocol>
  Like IP−SENDTO, but always uses IPv4.
  Option groups: FD,SOCKET,IP4
  IP6−SENDTO:<host>:<protocol>
  Like IP−SENDTO, but always uses IPv6.
  Option groups: 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.
  Option groups: FD, SOCKET, IP4, IP6, RANGE
  Useful options: bind, range, tcpwrap, broadcast, ip−multicast−loop,
  ip−multicast−ttl, ip−multicast−if, ip−add−membership, ttl, tos, pf
  See also: IP4−DATAGRAM, IP6−DATAGRAM, IP−SENDTO, IP−RECVFROM, IP−RECV,
  UDP−DATAGRAM
  IP4−DATAGRAM:<host>:<protocol>
  Like IP−DATAGRAM, but always uses IPv4. (example)
  Option groups: FD,SOCKET,IP4,RANGE
  IP6−DATAGRAM:<host>:<protocol>
  Like IP−DATAGRAM, but always uses IPv6. Please note that IPv6 does not
  know broadcasts.
  Option groups: 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.
  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.
  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.
  Option groups: FD,SOCKET,IP4,IP6,CHILD,RANGE
  Useful options: pf, fork, range, ttl, broadcast
  See also: IP4−RECVFROM, IP6−RECVFROM, IP−SENDTO, IP−RECV, UDP−RECVFROM,
  UNIX−RECVFROM
  IP4−RECVFROM:<protocol>
  Like IP−RECVFROM, but always uses IPv4.
  Option groups: FD,SOCKET,IP4,CHILD,RANGE
  IP6−RECVFROM:<protocol>
  Like IP−RECVFROM, but always uses IPv6.
  Option groups: FD,SOCKET,IP6,CHILD,RANGE
  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. 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.
  Option groups: FD,SOCKET,IP4,IP6,RANGE
  Useful options: pf, range
  See also: IP4−RECV, IP6−RECV, IP−SENDTO, IP−RECVFROM, UDP−RECV,
  UNIX−RECV
  IP4−RECV:<protocol>
  Like IP−RECV, but always uses IPv4.
  Option groups: FD,SOCKET,IP4,RANGE
  IP6−RECV:<protocol>
  Like IP−RECV, but always uses IPv6.
  Option groups: FD,SOCKET,IP6,RANGE
  OPEN:<filename>
  Opens <filename> using the open() system call (example). This operation
  fails on UNIX domain sockets.
  Note: This address type is rarly useful in bidirectional mode.
  Option groups: FD,REG,NAMED,OPEN
  Useful options: creat, excl, noatime, nofollow, append, rdonly, wronly,
  lock, readbytes, ignoreeof
  See also: 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.
  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
  certifications extension subjectAltName DNS names. Wildcards in the
  certificate are supported.
  Option groups: FD,SOCKET,IP4,IP6,TCP,OPENSSL,RETRY
  Useful options: cipher, method, verify, commonname cafile, capath,
  certificate, key, compress, bind, pf, connect−timeout, sourceport,
  retry
  See also: 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.
  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!
  Option groups: FD,SOCKET,IP4,IP6,TCP,LISTEN,OPENSSL,CHILD,RANGE,RETRY
  Useful options: pf, cipher, method, verify, commonname cafile, capath,
  certificate, key, compress, fork, bind, range, tcpwrap, su, reuseaddr,
  retry
  See also: OPENSSL, TCP−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
  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
  Option groups: FD,NAMED,OPEN
  Useful options: 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
  Option groups: FD
  See also: named pipe
  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. Note that the traffic need not be HTTP
  but can be an arbitrary protocol.
  Option groups: FD,SOCKET,IP4,IP6,TCP,HTTP,RETRY
  Useful options: proxyport, ignorecr, proxyauth, resolve, crnl, bind,
  connect−timeout, mss, sourceport, retry
  See also: 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).
  Option groups: FD,NAMED,PTY,TERMIOS
  Useful options: link, openpty, wait−slave, mode, user, group
  See also: UNIX−LISTEN, PIPE, EXEC, SYSTEM
  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.
  Option groups: FD,READLINE,TERMIOS
  Useful options: history, noecho
  See also: STDIO
  SCTP−CONNECT:<host>:<port>
  Establishes an SCTP stream connection to the specified <host> [IP
  address] and <port> [TCP service] using TCP/IP version 4 or 6 depending
  on address specification, name resolution, or option pf.
  Option groups: FD,SOCKET,IP4,IP6,SCTP,CHILD,RETRY
  Useful options: bind, pf, connect−timeout, tos, mtudiscover,
  sctp−maxseg, sctp−nodelay, nonblock, sourceport, retry, readbytes
  See also: SCTP4−CONNECT, SCTP6−CONNECT, SCTP−LISTEN, TCP−CONNECT
  SCTP4−CONNECT:<host>:<port>
  Like SCTP−CONNECT, but only supports IPv4 protocol.
  Option groups: FD,SOCKET,IP4,SCTP,CHILD,RETRY
  SCTP6−CONNECT:<host>:<port>
  Like SCTP−CONNECT, but only supports IPv6 protocol.
  Option groups: FD,SOCKET,IP6,SCTP,CHILD,RETRY
  SCTP−LISTEN:<port>
  Listens on <port> [TCP service] and accepts a TCP/IP 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.
  Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4,IP6,SCTP,RETRY
  Useful options: crnl, fork, bind, range, tcpwrap, pf, max−children,
  backlog, sctp−maxseg, sctp−nodelay, su, reuseaddr, retry, cool−write
  See also: SCTP4−LISTEN, SCTP6−LISTEN, TCP−LISTEN, SCTP−CONNECT
  SCTP4−LISTEN:<port>
  Like SCTP−LISTEN, but only supports IPv4 protocol.
  Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4,SCTP,RETRY
  SCTP6−LISTEN:<port>
  Like SCTP−LISTEN, but only supports IPv6 protocol.
  Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP6,SCTP,RETRY
  SOCKET−CONNECT:<domain>:<protocol>:<remote−address>
  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.
  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.
  Option groups: FD,SOCKET,CHILD,RETRY
  Useful options: bind, setsockopt−int, setsockopt−bin, setsockopt−string
  See also: TCP, UDP−CONNECT, UNIX−CONNECT, SOCKET−LISTEN, SOCKET−SENDTO
  SOCKET−DATAGRAM:<domain>:<type>:<protocol>:<remote−address>
  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.
  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.
  Option groups: FD,SOCKET,RANGE
  Useful options: bind, range, setsockopt−int, setsockopt−bin,
  setsockopt−string
  See also: 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.
  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.
  Option groups: FD,SOCKET,LISTEN,RANGE,CHILD,RETRY
  Useful options: setsockopt−int, setsockopt−bin, setsockopt−string
  See also: TCP, UDP−CONNECT, UNIX−CONNECT, SOCKET−LISTEN, SOCKET−SENDTO,
  SOCKET−SENDTO
  SOCKET−RECV:<domain>:<type>:<protocol>:<local−address>
  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.
  Option groups: FD,SOCKET,RANGE
  Useful options: range, setsockopt−int, setsockopt−bin,
  setsockopt−string
  See also: UDP−RECV, IP−RECV, UNIX−RECV, SOCKET−DATAGRAM, SOCKET−SENDTO,
  SOCKET−RECVFROM
  SOCKET−RECVFROM:<domain>:<type>:<protocol>:<local−address>
  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.
  Option groups: FD,SOCKET,CHILD,RANGE
  Useful options: fork, range, setsockopt−int, setsockopt−bin,
  setsockopt−string
  See also: UDP−RECVFROM, IP−RECVFROM, UNIX−RECVFROM, SOCKET−DATAGRAM,
  SOCKET−SENDTO, SOCKET−RECV
  SOCKET−SENDTO:<domain>:<type>:<protocol>:<remote−address>
  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.
  Option groups: FD,SOCKET
  Useful options: bind, setsockopt−int, setsockopt−bin, setsockopt−string
  See also: UDP−SENDTO, IP−SENDTO, UNIX−SENDTO, SOCKET−DATAGRAM,
  SOCKET−RECV SOCKET−RECVFROM
  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).
  Option groups: FD,SOCKET,IP4,IP6,TCP,SOCKS4,RETRY
  Useful options: socksuser, socksport, sourceport, pf, retry
  See also: 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.
  Option groups: FD,SOCKET,IP4,IP6,TCP,SOCKS4,RETRY
  STDERR
  Uses file descriptor 2.
  Option groups: FD (TERMIOS,REG,SOCKET)
  See also: FD
  STDIN
  Uses file descriptor 0.
  Option groups: FD (TERMIOS,REG,SOCKET)
  Useful options: readbytes
  See also: FD
  STDIO
  Uses file descriptor 0 for reading, and 1 for writing.
  Option groups: FD (TERMIOS,REG,SOCKET)
  Useful options: readbytes
  See also: FD
  STDOUT
  Uses file descriptor 1.
  Option groups: FD (TERMIOS,REG,SOCKET)
  See also: FD
  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.
  Option groups: FD,SOCKET,EXEC,FORK,TERMIOS
  Useful options: path, fdin, fdout, chroot, su, su−d, nofork, pty,
  stderr, ctty, setsid, pipes, sigint, sigquit
  See also: EXEC
  TCP:<host>:<port>
  Connects to <port> [TCP service] on <host> [IP address] using TCP/IP
  version 4 or 6 depending on address specification, name resolution, or
  option pf.
  Option groups: FD,SOCKET,IP4,IP6,TCP,RETRY
  Useful options: crnl, bind, pf, connect−timeout, tos, mtudiscover, mss,
  nodelay, nonblock, sourceport, retry, readbytes
  See also: TCP4, TCP6, TCP−LISTEN, UDP, SCTP−CONNECT, UNIX−CONNECT
  TCP4:<host>:<port>
  Like TCP, but only supports IPv4 protocol (example).
  Option groups: FD,SOCKET,IP4,TCP,RETRY
  TCP6:<host>:<port>
  Like TCP, but only supports IPv6 protocol.
  Option groups: FD,SOCKET,IP6,TCP,RETRY
  TCP−LISTEN:<port>
  Listens on <port> [TCP service] and accepts a TCP/IP 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.
  Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4,IP6,TCP,RETRY
  Useful options: crnl, fork, bind, range, tcpwrap, pf, max−children,
  backlog, mss, su, reuseaddr, retry, cool−write
  See also: TCP4−LISTEN, TCP6−LISTEN, UDP−LISTEN, SCTP−LISTEN,
  UNIX−LISTEN, OPENSSL−LISTEN, TCP−CONNECT
  TCP4−LISTEN:<port>
  Like TCP−LISTEN, but only supports IPv4 protocol (example).
  Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4,TCP,RETRY
  TCP6−LISTEN:<port>
  Like TCP−LISTEN, but only supports IPv6 protocol.
  Additional useful option: ipv6only
  Option groups: 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!
  Option groups: FD,NAMED,OPEN,TUN
  Useful options: iff−up, tun−device, tun−name, tun−type, iff−no−pi
  See also: 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.
  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.
  Option groups: FD,SOCKET,IP4,IP6
  Useful options: ttl, tos, bind, sourceport, pf
  See also: UDP4, UDP6, UDP−LISTEN, TCP, IP
  UDP4:<host>:<port>
  Like UDP, but only supports IPv4 protocol.
  Option groups: FD,SOCKET,IP4
  UDP6:<host>:<port>
  Like UDP, but only supports IPv6 protocol.
  Option groups: 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 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.
  Option groups: FD,SOCKET,IP4,IP6,RANGE
  Useful options: bind, range, tcpwrap, broadcast, ip−multicast−loop,
  ip−multicast−ttl, ip−multicast−if, ip−add−membership, ttl, tos,
  sourceport, pf
  See also: UDP4−DATAGRAM, UDP6−DATAGRAM, UDP−SENDTO, UDP−RECVFROM,
  UDP−RECV, UDP−CONNECT, UDP−LISTEN, IP−DATAGRAM
  UDP4−DATAGRAM:<address>:<port>
  Like UDP−DATAGRAM, but only supports IPv4 protocol (example1,
  example2).
  Option groups: FD,SOCKET,IP4, RANGE
  UDP6−DATAGRAM:<address>:<port>
  Like UDP−DATAGRAM, but only supports IPv6 protocol.
  Option groups: 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.
  Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4,IP6
  Useful options: fork, bind, range, pf
  See also: UDP, UDP4−LISTEN, UDP6−LISTEN, TCP−LISTEN
  UDP4−LISTEN:<port>
  Like UDP−LISTEN, but only support IPv4 protocol.
  Option groups: FD,SOCKET,LISTEN,CHILD,RANGE,IP4
  UDP6−LISTEN:<port>
  Like UDP−LISTEN, but only support IPv6 protocol.
  Option groups: 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.
  Option groups: FD,SOCKET,IP4,IP6
  Useful options: ttl, tos, bind, sourceport, pf
  See also: 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.
  Option groups: FD,SOCKET,IP4
  UDP6−SENDTO:<host>:<port>
  Like UDP−SENDTO, but only supports IPv6 protocol.
  Option groups: 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.
  Option groups: FD,SOCKET,IP4,IP6,CHILD,RANGE
  Useful options: 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:<port>
  Like UDP−RECVFROM, but only supports IPv4 protocol.
  Option groups: FD,SOCKET,IP4,CHILD,RANGE
  UDP6−RECVFROM:<port>
  Like UDP−RECVFROM, but only supports IPv6 protocol.
  Option groups: 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.
  Option groups: FD,SOCKET,IP4,IP6,RANGE
  Useful options: fork, 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:<port>
  Like UDP−RECV, but only supports IPv4 protocol.
  Option groups: FD,SOCKET,IP4,RANGE
  UDP6−RECV:<port>
  Like UDP−RECV, but only supports IPv6 protocol.
  Option groups: FD,SOCKET,IP6,RANGE
  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.
  Option groups: FD,SOCKET,NAMED,RETRY,UNIX
  ) Useful options: bind
  See also: 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).
  Option groups: FD,SOCKET,NAMED,LISTEN,CHILD,RETRY,UNIX
  Useful options: fork, umask, mode, user, group, unlink−early
  See also: 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 neccessary 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.
  Option groups: FD,SOCKET,NAMED,UNIX
  Useful options: bind
  See also: 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.
  Option groups: FD,SOCKET,NAMED,CHILD,UNIX
  Useful options: fork
  See also: 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. It can be, e.g., addressed by socat UNIX−SENDTO address
  peers. It behaves similar to a syslog server. Option groups:
  FD,SOCKET,NAMED,UNIX
  See also: 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.
  Option groups: FD,SOCKET,NAMED,UNIX
  Useful options: bind
  See also: UNIX−CONNECT, UNIX−SENDTO, GOPEN
  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 archieve this the socket
  address strings are prefixed with "\0" internally. This feature is
  available (only?) on Linux. Option groups are the same as with the
  related UNIX addresses, except that the ABSTRACT addresses are not
  member of the NAMED group.


  Performs a chroot() operation to <directory> before opening the
  address. This call might require root privilege.
  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.
  setgid−early=<group>
  Like setgit but is performed before opening the address.
  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.
  setuid−early=<user>
  Like setuid but is performed before opening the address.
  su=<user>
  Changes the <user> (owner) and groups of the process after processing
  the address (example). This call might require root privilege.
  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.
  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.
  setsid
  Makes the process the leader of a new session (example).
  READLINE option group
  These options apply to the readline address type.
  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.
  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)
  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 archieved.
  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.
  cr
  Converts the default line termination character NL (’\n’, 0x0a) to/from
  CR (’\r’, 0x0d) when writing/reading on this channel.
  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.
  ignoreeof
  When EOF occurs on this channel, socat ignores it and tries to read
  more data (like "tail −f") (example).
  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.
  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).
  SOCKET option group
  These options are intended for all kinds of sockets, e.g. IP or UNIX
  domain. Most are applied with a setsockopt() call.
  bind=<sockname>
  Binds the socket to the given socket address using the bind() system
  call. The form of <sockname> is socket domain dependent: IP4 and IP6
  allow the form [hostname|hostaddress][:(service|port)] (example), UNIX
  domain sockets require <filename>.
  connect−timeout=<seconds>
  Abort the connection attempt after <seconds> [timeval] with error
  status.
  so−bindtodevice=<interface>
  Binds the socket to the given <interface>. This option might require
  root privilege.
  broadcast
  For datagram sockets, allows sending to broadcast addresses and
  receiving packets addressed to broadcast addresses.
  debug
  Enables socket debugging.
  dontroute
  Only communicates with directly connected peers, does not use routers.
  keepalive
  Enables sending keepalives on the socket.
  linger=<seconds>
  Blocks shutdown() or close() until data transfers have finished or the
  given timeout [int] expired.
  oobinline
  Places out−of−band data in the input data stream.
  priority=<priority>
  Sets the protocol defined <priority> [<int>] for outgoing packets.
  rcvbuf=<bytes>
  Sets the size of the receive buffer after the socket() call to <bytes>
  [int]. With TCP sockets, this value corresponds to the socket’s maximal
  window size.
  rcvbuf−late=<bytes>
  Sets the size of the receive buffer when the socket is already
  connected to <bytes> [int]. With TCP sockets, this value corresponds to
  the socket’s maximal window size.
  rcvlowat=<bytes>
  Specifies the minimum number of received bytes [int] until the socket
  layer will pass the buffered data to socat.
  rcvtimeo=<seconds>
  Sets the receive timeout [timeval].
  reuseaddr
  Allows other sockets to bind to an address even if parts of it (e.g.
  the local port) are already in use by socat (example).
  sndbuf=<bytes>
  Sets the size of the send buffer after the socket() call to <bytes>
  [int].
  sndbuf−late=<bytes>
  Sets the size of the send buffer when the socket is connected to
  <bytes> [int].
  sndlowat=<bytes>
  Specifies the minimum number of bytes in the send buffer until the
  socket layer will send the data to <bytes> [int].
  sndtimeo=<seconds>
  Sets the send timeout to seconds [timeval].
  pf=<string>
  Forces the use of the specified IP version or protocol. <string> can be
  something like "ip4" or "ip6". The resulting value is used as first
  argument to the socket() or socketpair() calls. This option affects
  address resolution and the required syntax of bind and range options.
  type=<type>
  Sets the type of the socket, specified as second argument to the
  socket() or socketpair() calls, to <type> [int]. Address resolution is
  not affected by this option. Under Linux, 1 means stream oriented
  socket, 2 means datagram socket, and 3 means raw socket.
  prototype
  Sets the protocol of the socket, specified as third argument to the
  socket() or socketpair() calls, to <prototype> [int]. Address
  resolution is not affected by this option. 6 means TCP, 17 means UDP.
  so−timestamp
  Sets the SO_TIMESTAMP socket option. This enables receiving and logging
  of timestamp ancillary messages.
  setsockopt−int=<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. The
  4th setsockopt() parameter, value [int], is passed to the function per
  pointer, and for the length parameter sizeof\(int) is taken
  implicitely.
  setsockopt−bin=<level>:<optname>:<optval>
  Like setsockopt−int, but <optval> must be provided in dalan format and
  specifies an arbitrary sequence of bytes; the length parameter is
  automatically derived from the data.
  setsockopt−string=<level>:<optname>:<optval>
  Like setsockopt−int, but <optval> must be a string. This string is
  passed to the function with trailing null character, and the length
  parameter is automatically derived from the data.
  UNIX option group
  These options apply to UNIX domain based addresses.
  unix−tightsocklen=[0|1]
  On socket operations, pass a socket address length that does not
  include the whole struct sockaddr_un record but (besides other
  components) only the relevant part of the filename or abstract string.
  Default is 1.
  IP4 and IP6 option groups
  These options can be used with IPv4 and IPv6 based sockets.
  tos=<tos>
  Sets the TOS (type of service) field of outgoing packets to <tos>
  [byte] (see RFC 791).
  ttl=<ttl>
  Sets the TTL (time to live) field of outgoing packets to <ttl> [byte].
  ip−options=
  Sets IP options like source routing. Must be given in binary form,
  recommended format is a leading "x" followed by an even number of hex
  digits. This option may be used multiple times, data are appended.
  E.g., to connect to host 10.0.0.1 via some gateway using a loose source
  route, use the gateway as address parameter and set a loose source
  route using the option ip−options=x8307040a000001 .
  IP options are defined in RFC 791.
  mtudiscover=<0|1|2>
  Takes 0, 1, 2 to never, want, or always use path MTU discover on this
  socket.
  ip−pktinfo
  Sets the IP_PKTINFO socket option. This enables receiving and logging
  of ancillary messages containing destination address and interface
  (Linux) (example).
  ip−recverr
  Sets the IP_RECVERR socket option. This enables receiving and logging
  of ancillary messages containing detailled error information.
  ip−recvopts
  Sets the IP_RECVOPTS socket option. This enables receiving and logging
  of IP options ancillary messages (Linux, *BSD).
  ip−recvtos
  Sets the IP_RECVTOS socket option. This enables receiving and logging
  of TOS (type of service) ancillary messages (Linux).
  ip−recvttl
  Sets the IP_RECVTTL socket option. This enables receiving and logging
  of TTL (time to live) ancillary messages (Linux, *BSD).
  ip−recvdstaddr
  Sets the IP_RECVDSTADDR socket option. This enables receiving and
  logging of ancillary messages containing destination address (*BSD)
  (example).
  ip−recvif
  Sets the IP_RECVIF socket option. This enables receiving and logging of
  interface ancillary messages (*BSD) (example).
  ip−add−membership=<multicast−address:interface−address>
  ip−add−membership=<multicast−address:interface−name>
  ip−add−membership=<multicast−address:interface−index>
  ip−add−membership=<multicast−address:interface−address:interface−name>
  ip−add−membership=<multicast−address:interface−address:interface−index>
  Makes the socket member of the specified multicast group. This is
  currently only implemented for IPv4. The option takes the IP address of
  the multicast group and info about the desired network interface. The
  most common syntax is the first one, while the others are only
  available on systems that provide struct mreqn (Linux).
  The indices of active network interfaces can be shown using the utility
  procan.
  ip−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.
  res−debug
  res−aaonly
  res−usevc
  res−primary
  res−igntc
  res−recurse
  res−defnames
  res−stayopen
  res−dnsrch
  These options set the corresponding resolver (name resolution) option
  flags. Append "=0" to clear a default option. See man resolver\(5) for
  more information on these options. Note: these options are valid only
  for the address they are applied to.
  IP6 option group
  These options can only be used on IPv6 based sockets. See IP options
  for options that can be applied to both IPv4 and IPv6 sockets.
  ipv6only=<bool>
  Sets the IPV6_V6ONLY socket option. If 0, the TCP stack will also
  accept connections using IPv4 protocol on the same port. The default is
  system dependent.
  ipv6−recvdstopts
  Sets the IPV6_RECVDSTOPTS socket option. This enables receiving and
  logging of ancillary messages containing the destination options.
  ipv6−recvhoplimit
  Sets the IPV6_RECVHOPLIMIT socket option. This enables receiving and
  logging of ancillary messages containing the hoplimit.
  ipv6−recvhopopts
  Sets the IPV6_RECVHOPOPTS socket option. This enables receiving and
  logging of ancillary messages containing the hop options.
  ipv6−recvpktinfo
  Sets the IPV6_RECVPKTINFO socket option. This enables receiving and
  logging of ancillary messages containing destination address and
  interface.
  ipv6−unicast−hops=link(TYPE_INT)(<int>)
  Sets the IPV6_UNICAST_HOPS socket option. This sets the hop count limit
  (TTL) for outgoing unicast packets.
  ipv6−recvrthdr
  Sets the IPV6_RECVRTHDR socket option. This enables receiving and
  logging of ancillary messages containing routing information.
  ipv6−tclass
  Sets the IPV6_TCLASS socket option. This sets the transfer class of
  outgoing packets.
  ipv6−recvtclass
  Sets the IPV6_RECVTCLASS socket option. This enables receiving and
  logging of ancillary messages containing the transfer class.
  TCP option group
  These options may be applied to TCP sockets. They work by invoking
  setsockopt() with the appropriate parameters.
  cork
  Doesn’t send packets smaller than MSS (maximal segment size).
  defer−accept
  While listening, accepts connections only when data from the peer
  arrived.
  keepcnt=<count>
  Sets the number of keepalives before shutting down the socket to
  <count> [int].
  keepidle=<seconds>
  Sets the idle time before sending the first keepalive to <seconds>
  [int].
  keepintvl=<seconds>
  Sets the interval between two keepalives to <seconds> [int].
  linger2=<seconds>
  Sets the time to keep the socket in FIN−WAIT−2 state to <seconds>
  [int].
  mss=<bytes>
  Sets the MSS (maximum segment size) after the socket() call to <bytes>
  [int]. This value is then proposed to the peer with the SYN or SYN/ACK
  packet (example).
  mss−late=<bytes>
  Sets the MSS of the socket after connection has been established to
  <bytes> [int].
  nodelay
  Turns off the Nagle algorithm for measuring the RTT (round trip time).
  rfc1323
  Enables RFC1323 TCP options: TCP window scale, round−trip time
  measurement (RTTM), and protect against wrapped sequence numbers (PAWS)
  (AIX).
  stdurg
  Enables RFC1122 compliant urgent pointer handling (AIX).
  syncnt=<count>
  Sets the maximal number of SYN retransmits during connect to <count>
  [int].
  md5sig
  Enables generation of MD5 digests on the packets (FreeBSD).
  noopt
  Disables use of TCP options (FreeBSD, MacOSX).
  nopush
  sets the TCP_NOPUSH socket option (FreeBSD, MacOSX).
  sack−disable
  Disables use the selective acknowledge feature (OpenBSD).
  signature−enable
  Enables generation of MD5 digests on the packets (OpenBSD).
  abort−threshold=<milliseconds>
  Sets the time to wait for an answer of the peer on an established
  connection (HP−UX).
  conn−abort−threshold=<milliseconds>
  Sets the time to wait for an answer of the server during the initial
  connect (HP−UX).
  keepinit
  Sets the time to wait for an answer of the server during connect\()
  before giving up. Value in half seconds, default is 150 (75s) (Tru64).
  paws
  Enables the "protect against wrapped sequence numbers" feature (Tru64).
  sackena
  Enables selective acknowledge (Tru64).
  tsoptena
  Enables the time stamp option that allows RTT recalculation on existing
  connections (Tru64).
  SCTP option group
  These options may be applied to SCTP stream sockets.
  sctp−nodelay
  Sets the SCTP_NODELAY socket option that disables the Nagle algorithm.
  sctp−maxseg=<bytes>
  Sets the SCTP_MAXSEG socket option to <bytes> [int]. This value is then
  proposed to the peer with the SYN or SYN/ACK packet.
  UDP, TCP, and SCTP option groups
  Here we find options that are related to the network port mechanism and
  thus can be used with UDP, TCP, and SCTP client and server addresses.
  sourceport=<port>
  For outgoing (client) TCP and UDP connections, it sets the source
  <port> using an extra bind() call. With TCP or UDP listen addresses,
  socat immediately shuts down the connection if the client does not use
  this sourceport (example).
  lowport
  Outgoing (client) TCP and UDP connections with this option use an
  unused random source port between 640 and 1023 incl. On UNIX class
  operating systems, this requires root privilege, and thus indicates
  that the client process is authorized by local root. TCP and UDP listen
  addresses with this option immediately shut down the connection if the
  client does not use a sourceport <= 1023. This mechanism can provide
  limited authorization under some circumstances.
  SOCKS option group
  When using SOCKS type addresses, some socks specific options can be
  set.
  socksport=<tcp service>
  Overrides the default "socks" service or port 1080 for the socks server
  port with <TCP service>.
  socksuser=<user>
  Sends the <user> [string] in the username field to the socks server.
  Default is the actual user name ($LOGNAME or $USER) (example).
  HTTP option group
  Options that can be provided with HTTP type addresses. The only HTTP
  address currently implemented is proxy−connect.
  proxyport=<TCP service>
  Overrides the default HTTP proxy port 8080 with <TCP service>.
  ignorecr
  The HTTP protocol requires the use of CR+NL as line terminator. When a
  proxy server violates this standard, socat might not understand its
  answer. This option directs socat to interprete NL as line terminator
  and to ignore CR in the answer. Nevertheless, socat sends CR+NL to the
  proxy.
  proxyauth=<username>:<password>
  Provide "basic" authentication to the proxy server. The argument to the
  option is used with a "Proxy−Authorization: Base" header in base64
  encoded form.
  Note: username and password are visible for every user on the local
  machine in the process list; username and password are transferred to
  the proxy server unencrypted (base64 encoded) and might be sniffed.
  resolve
  Per default, socat sends to the proxy a CONNECT request containing the
  target hostname. With this option, socat resolves the hostname locally
  and sends the IP address. Please note that, according to RFC 2396, only
  name resolution to IPv4 addresses is implemented.
  RANGE option group
  These options check if a connecting client should be granted access.
  They can be applied to listening and receiving network sockets.
  tcp−wrappers options fall into this group.
  range=<address−range>
  After accepting a connection, tests if the peer is within range. For
  IPv4 addresses, address−range takes the form address/bits, e.g.
  10.0.0.0/8, or address:mask, e.g. 10.0.0.0:255.0.0.0 (example); for
  IPv6, it is [ip6−address/bits], e.g. [::1/128]. If the client address
  does not match, socat issues a warning and keeps listening/receiving.
  tcpwrap[=<name>]
  Uses Wietse Venema’s libwrap (tcpd) library to determine if the client
  is allowed to connect. The configuration files are /etc/hosts.allow and
  /etc/hosts.deny per default, see "man 5 hosts_access" for more
  information. The optional <name> (type string) is passed to the wrapper
  functions as daemon process name (example). If omitted, the basename of
  socats invocation (argv[0]) is passed. If both tcpwrap and range
  options are applied to an address, both conditions must be fulfilled to
  allow the connection.
  allow−table=<filename>
  Takes the specified file instead of /etc/hosts.allow.
  deny−table=<filename>
  Takes the specified file instead of /etc/hosts.deny.
  tcpwrap−etc=<directoryname>
  Looks for hosts.allow and hosts.deny in the specified directory. Is
  overridden by options hosts−allow and hosts−deny.
  LISTEN option group
  Options specific to listening sockets.
  backlog=<count>
  Sets the backlog value passed with the listen() system call to <count>
  [int]. Default is 5.
  max−children=<count>
  Limits the number of concurrent child processes [int]. Default is no
  limit.
  CHILD option group
  Options for addresses with multiple connections via child processes.
  fork
  After establishing a connection, handles its channel in a child process
  and keeps the parent process attempting to produce more connections,
  either by listening or by connecting in a loop (example).
  SSL−CONNECT and SSL−LISTEN differ in when they actually fork off the
  child: SSL−LISTEN forks before the SSL handshake, while SSL−CONNECT
  forks afterwards. RETRY and FOREVER options are not inherited by the
  child process.
  On some operating systems (e.g. FreeBSD) this option does not work for
  UDP−LISTEN addresses.
  EXEC option group
  Options for addresses that invoke a program.
  path=<string>
  Overrides the PATH environment variable for searching the program with
  <string>. This $PATH value is effective in the child process too.
  login
  Prefixes argv[0] for the execvp() call with ’−’, thus making a shell
  behave as login shell.
  FORK option group
  EXEC or SYSTEM addresses invoke a program using a child process and
  transfer data between socat and the program. The interprocess
  communication mechanism can be influenced with the following options.
  Per default, a socketpair() is created and assigned to stdin and stdout
  of the child process, while stderr is inherited from the socat process,
  and the child process uses file descriptors 0 and 1 for communicating
  with the main socat process.
  nofork
  Does not fork a subprocess for executing the program, instead calls
  execvp\() or system\() directly from the actual socat instance. This
  avoids the overhead of another process between the program and its
  peer, but introduces a lot of restrictions:
  o
  this option can only be applied to the second socat address.
  o
  it cannot be applied to a part of a dual address.
  o
  the first socat address cannot be OPENSSL or READLINE
  o
  socat options −b, −t, −D, −l, −v, −x become useless
  o
  for both addresses, options ignoreeof, cr, and crnl become useless
  o
  for the second address (the one with option nofork), options append,
  cloexec, flock, user, group, mode, nonblock, perm−late, setlk, and
  setpgid cannot be applied. Some of these could be used on the first
  address though.
  pipes
  Creates a pair of unnamed pipes for interprocess communication instead
  of a socket pair.
  openpty
  Establishes communication with the sub process using a pseudo terminal
  created with openpty() instead of the default (socketpair or ptmx).
  ptmx
  Establishes communication with the sub process using a pseudo terminal
  created by opening /dev/ptmx or /dev/ptc instead of the default
  (socketpair).
  pty
  Establishes communication with the sub process using a pseudo terminal
  instead of a socket pair. Creates the pty with an available mechanism.
  If openpty and ptmx are both available, it uses ptmx because this is
  POSIX compliant (example).
  ctty
  Makes the pty the controlling tty of the sub process (example).
  stderr
  Directs stderr of the sub process to its output channel by making
  stderr a dup() of stdout (example).
  fdin=<fdnum>
  Assigns the sub processes input channel to its file descriptor <fdnum>
  instead of stdin (0). The program started from the subprocess has to
  use this fd for reading data from socat (example).
  fdout=<fdnum>
  Assigns the sub processes output channel to its file descriptor <fdnum>
  instead of stdout (1). The program started from the subprocess has to
  use this fd for writing data to socat (example).
  sighup, sigint, sigquit
  Has socat pass signals of this type to the sub process. If no address
  has this option, socat terminates on these signals.
  TERMIOS option group
  For addresses that work on a tty (e.g., stdio, file:/dev/tty,
  exec:...,pty), the terminal parameters defined in the UN*X termios
  mechanism are made available as address option parameters. Please note
  that changes of the parameters of your interactive terminal remain
  effective after socat’s termination, so you might have to enter "reset"
  or "stty sane" in your shell afterwards. For EXEC and SYSTEM addresses
  with option PTY, these options apply to the pty by the child processes.
  b0
  Disconnects the terminal.
  b19200
  Sets the serial line speed to 19200 baud. Some other rates are
  possible; use something like socat −hh |grep ’ b[1−9]’ to find all
  speeds supported by your implementation.
  Note: On some operating systems, these options may not be available.
  Use ispeed or ospeed instead.
  echo=<bool>
  Enables or disables local echo.
  icanon=<bool>
  Sets or clears canonical mode, enabling line buffering and some special
  characters.
  raw
  Sets raw mode, thus passing input and output almost unprocessed. This
  option is obsolete, use option rawer or cfmakeraw instead.
  rawer
  Makes terminal rawer than raw option. This option implicitly turns off
  echo. (example).
  cfmakeraw
  Sets raw mode by invoking cfmakeraw() or by simulating this call. This
  option implicitly turns off echo.
  ignbrk=<bool>
  Ignores or interpretes the BREAK character (e.g., ^C)
  brkint=<bool>
  bs0
  bs1
  bsdly=<0|1>
  clocal=<bool>
  cr0
  cr1
  cr2
  cr3
  Sets the carriage return delay to 0, 1, 2, or 3, respectively. 0 means
  no delay, the other values are terminal dependent.
  crdly=<0|1|2|3>
  cread=<bool>
  crtscts=<bool>
  cs5
  cs6
  cs7
  cs8
  Sets the character size to 5, 6, 7, or 8 bits, respectively.
  csize=<0|1|2|3>
  cstopb=<bool>
  Sets two stop bits, rather than one.
  dsusp=<byte>
  Sets the value for the VDSUSP character that suspends the current
  foreground process and reactivates the shell (all except Linux).
  echoctl=<bool>
  Echos control characters in hat notation (e.g. ^A)
  echoe=<bool>
  echok=<bool>
  echoke=<bool>
  echonl=<bool>
  echoprt=<bool>
  eof=<byte>
  eol=<byte>
  eol2=<byte>
  erase=<byte>
  discard=<byte>
  ff0
  ff1
  ffdly=<bool>
  flusho=<bool>
  hupcl=<bool>
  icrnl=<bool>
  iexten=<bool>
  igncr=<bool>
  ignpar=<bool>
  imaxbel=<bool>
  inlcr=<bool>
  inpck=<bool>
  intr=<byte>
  isig=<bool>
  ispeed=<unsigned−int>
  Set the baud rate for incoming data on this line.
  See also: ospeed, b19200
  istrip=<bool>
  iuclc=<bool>
  ixany=<bool>
  ixoff=<bool>
  ixon=<bool>
  kill=<byte>
  lnext=<byte>
  min=<byte>
  nl0
  Sets the newline delay to 0.
  nl1
  nldly=<bool>
  noflsh=<bool>
  ocrnl=<bool>
  ofdel=<bool>
  ofill=<bool>
  olcuc=<bool>
  onlcr=<bool>
  onlret=<bool>
  onocr=<bool>
  opost=<bool>
  Enables or disables output processing; e.g., converts NL to CR−NL.
  ospeed=<unsigned−int>
  Set the baud rate for outgoing data on this line.
  See also: ispeed, b19200
  parenb=<bool>
  Enable parity generation on output and parity checking for input.
  parmrk=<bool>
  parodd=<bool>
  pendin=<bool>
  quit=<byte>
  reprint=<byte>
  sane
  Brings the terminal to something like a useful default state.
  start=<byte>
  stop=<byte>
  susp=<byte>
  swtc=<byte>
  tab0
  tab1
  tab2
  tab3
  tabdly=<unsigned−int>
  time=<byte>
  tostop=<bool>
  vt0
  vt1
  vtdly=<bool>
  werase=<byte>
  xcase=<bool>
  xtabs
  i−pop−all
  With UNIX System V STREAMS, removes all drivers from the stack.
  i−push=<string>
  With UNIX System V STREAMS, pushes the driver (module) with the given
  name (string) onto the stack. For example, to make sure that a
  character device on Solaris supports termios etc, use the following
  options: i−pop−all,i−push=ptem,i−push=ldterm,i−push=ttcompat
  PTY option group
  These options are intended for use with the pty address type.
  link=<filename>
  Generates a symbolic link that points to the actual pseudo terminal
  (pty). This might help to solve the problem that ptys are generated
  with more or less unpredictable names, making it difficult to directly
  access the socat generated pty automatically. With this option, the
  user can specify a "fix" point in the file hierarchy that helps him to
  access the actual pty (example). Beginning with socat version 1.4.3,
  the symbolic link is removed when the address is closed (but see option
  unlink−close).
  wait−slave
  Blocks the open phase until a process opens the slave side of the pty.
  Usually, socat continues after generating the pty with opening the next
  address or with entering the transfer loop. With the wait−slave option,
  socat waits until some process opens the slave side of the pty before
  continuing. This option only works if the operating system provides the
  poll() system call. And it depends on an undocumented behaviour of
  pty’s, so it does not work on all operating systems. It has
  successfully been tested on Linux, FreeBSD, NetBSD, and on Tru64 with
  openpty.
  pty−interval=<seconds>
  When the wait−slave option is set, socat periodically checks the HUP
  condition using poll() to find if the pty’s slave side has been opened.
  The default polling interval is 1s. Use the pty−interval option
  [timeval] to change this value.
  OPENSSL option group
  These options apply to the openssl and openssl−listen address types.
  cipher=<cipherlist>
  Selects the list of ciphers that may be used for the connection. See
  the man page of ciphers , section CIPHER LIST FORMAT, for detailed
  information about syntax, values, and default of <cipherlist>.
  Several cipher strings may be given, separated by ’:’. Some simple
  cipher strings:
  3DES
  Uses a cipher suite with triple DES.
  MD5
  Uses a cipher suite with MD5.
  aNULL
  Uses a cipher suite without authentication.
  NULL
  Does not use encryption.
  HIGH
  Uses a cipher suite with "high" encryption. Note that the peer must
  support the selected property, or the negotiation will fail.
  method=<ssl−method>
  Sets the protocol version to be used. Valid strings (not case
  sensitive) are:
  SSL2
  Select SSL protocol version 2.
  SSL3
  Select SSL protocol version 3.
  SSL23
  Select the best available SSL or TLS protocol. This is the default when
  this option is not provided.
  TLS1
  Select TLS protocol version 1.
  TLS1.1
  Select TLS protocol version 1.1.
  TLS1.2
  Select TLS protocol version 1.2.
  DTLS1
  Select DTLS protocol version 1.
  verify=<bool>
  Controls check of the peer’s certificate. Default is 1 (true).
  Disabling verify might open your socket for everyone, making the
  encryption useless!
  cert=<filename>
  Specifies the file with the certificate and private key for
  authentication. The certificate must be in OpenSSL format (*.pem). With
  openssl−listen, use of this option is strongly recommended. Except with
  cipher aNULL, "no shared ciphers" error will occur when no certificate
  is given.
  key=<filename>
  Specifies the file with the private key. The private key may be in this
  file or in the file given with the cert option. The party that has to
  proof that it is the owner of a certificate needs the private key.
  dhparams=<filename>
  Specifies the file with the Diffie Hellman parameters. These parameters
  may also be in the file given with the cert option in which case the
  dhparams option is not needed.
  cafile=<filename>
  Specifies the file with the trusted (root) authority certificates. The
  file must be in PEM format and should contain one or more certificates.
  The party that checks the authentication of its peer trusts only
  certificates that are in this file.
  capath=<dirname>
  Specifies the directory with the trusted (root) certificates. The
  directory must contain certificates in PEM format and their hashes (see
  OpenSSL documentation)
  egd=<filename>
  On some systems, openssl requires an explicit source of random data.
  Specify the socket name where an entropy gathering daemon like egd
  provides random data, e.g. /dev/egd−pool.
  pseudo
  On systems where openssl cannot find an entropy source and where no
  entropy gathering daemon can be utilized, this option activates a
  mechanism for providing pseudo entropy. This is archieved by taking the
  current time in microseconds for feeding the libc pseudo random number
  generator with an initial value. openssl is then feeded with output
  from random\() calls.
  NOTE:This mechanism is not sufficient for generation of secure keys!
  compress
  Enable or disable the use of compression for a connection. Setting this
  to "none" disables compression, setting it to "auto" lets OpenSSL
  choose the best available algorithm supported by both parties. The
  default is to not touch any compression−related settings. NOTE:
  Requires OpenSSL 0.9.8 or higher and disabling compression with OpenSSL
  0.9.8 affects all new connections in the process.
  commonname=<string>
  Specify the commonname that the peer certificate must match. With
  OPENSSL−CONNECT address this overrides the given hostname or IP target
  address; with OPENSSL−LISTEN this turns on check of peer certificates
  commonname. This option has only meaning when option verify is not
  disabled and the choosen cipher provides a peer certificate.
  fips
  Enables FIPS mode if compiled in. For info about the FIPS encryption
  implementation standard see http://oss−institute.org/fips−faq.html.
  This mode might require that the involved certificates are generated
  with a FIPS enabled version of openssl. Setting or clearing this option
  on one socat address affects all OpenSSL addresses of this process.
  RETRY option group
  Options that control retry of some system calls, especially connection
  attempts.
  retry=<num>
  Number of retries before the connection or listen attempt is aborted.
  Default is 0, which means just one attempt.
  interval=<timespec>
  Time between consecutive attempts (seconds, [timespec]). Default is 1
  second.
  forever
  Performs an unlimited number of retry attempts.
  TUN option group
  Options that control Linux TUN/TAP interface device addresses.
  tun−device=<device−file>
  Instructs socat to take another path for the TUN clone device. Default
  is /dev/net/tun.
  tun−name=<if−name>
  Gives the resulting network interface a specific name instead of the
  system generated (tun0, tun1, etc.)
  tun−type=[tun|tap]
  Sets the type of the TUN device; use this option to generate a TAP
  device. See the Linux docu for the difference between these types. When
  you try to establish a tunnel between two TUN devices, their types
  should be the same.
  iff−no−pi
  Sets the IFF_NO_PI flag which controls if the device includes
  additional packet information in the tunnel. When you try to establish
  a tunnel between two TUN devices, these flags should have the same
  values.
  iff−up
  Sets the TUN network interface status UP. Strongly recommended.
  iff−broadcast
  Sets the BROADCAST flag of the TUN network interface.
  iff−debug
  Sets the DEBUG flag of the TUN network interface.
  iff−loopback
  Sets the LOOPBACK flag of the TUN network interface.
  iff−pointopoint
  Sets the POINTOPOINT flag of the TUN device.
  iff−notrailers
  Sets the NOTRAILERS flag of the TUN device.
  iff−running
  Sets the RUNNING flag of the TUN device.
  iff−noarp
  Sets the NOARP flag of the TUN device.
  iff−promisc
  Sets the PROMISC flag of the TUN device.
  iff−allmulti
  Sets the ALLMULTI flag of the TUN device.
  iff−master
  Sets the MASTER flag of the TUN device.
  iff−slave
  Sets the SLAVE flag of the TUN device.
  iff−multicast
  Sets the MULTICAST flag of the TUN device.
  iff−portsel
  Sets the PORTSEL flag of the TUN device.
  iff−automedia
  Sets the AUTOMEDIA flag of the TUN device.
  iff−dynamic
  Sets the DYNAMIC flag of the TUN device.

DATA VALUES

  This section explains the different data types that address parameters
  and address options can take.
  address−range
  Is currently only implemented for IPv4 and IPv6. See address−option
  ‘range’
  bool
  "0" or "1"; if value is omitted, "1" is taken.
  byte
  An unsigned int number, read with strtoul() , lower or equal to
  UCHAR_MAX .
  command−line
  A string specifying a program name and its arguments, separated by
  single spaces.
  data
  A raw data specification following dalan syntax. Currently the only
  valid form is a string starting with ’x’ followed by an even number of
  hex digits, specifying a sequence of bytes.
  directory
  A string with usual UN*X directory name semantics.
  facility
  The name of a syslog facility in lower case characters.
  fdnum
  An unsigned int type, read with strtoul() , specifying a UN*X file
  descriptor.
  filename
  A string with usual UN*X filename semantics.
  group
  If the first character is a decimal digit, the value is read with
  strtoul() as unsigned integer specifying a group id. Otherwise, it must
  be an existing group name.
  int
  A number following the rules of the strtol() function with base "0",
  i.e. decimal number, octal number with leading "0", or hexadecimal
  number with leading "0x". The value must fit into a C int.
  interface
  A string specifying the device name of a network interface as shown by
  ifconfig or procan, e.g. "eth0".
  IP address
  An IPv4 address in numbers−and−dots notation, an IPv6 address in hex
  notation enclosed in brackets, or a hostname that resolves to an IPv4
  or an IPv6 address.
  Examples: 127.0.0.1, [::1], www.dest−unreach.org, dns1
  IPv4 address
  An IPv4 address in numbers−and−dots notation or a hostname that
  resolves to an IPv4 address.
  Examples: 127.0.0.1, www.dest−unreach.org, dns2
  IPv6 address
  An iPv6 address in hexnumbers−and−colons notation enclosed in brackets,
  or a hostname that resolves to an IPv6 address.
  Examples: [::1], [1234:5678:9abc:def0:1234:5678:9abc:def0],
  ip6name.domain.org
  long
  A number read with strtol() . The value must fit into a C long.
  long long
  A number read with strtoll() . The value must fit into a C long long.
  off_t
  An implementation dependend signed number, usually 32 bits, read with
  strtol or strtoll.
  off64_t
  An implementation dependend signed number, usually 64 bits, read with
  strtol or strtoll.
  mode_t
  An unsigned integer, read with strtoul() , specifying mode (permission)
  bits.
  pid_t
  A number, read with strtol() , specifying a process id.
  port
  A uint16_t (16 bit unsigned number) specifying a TCP or UDP port, read
  with strtoul() .
  protocol
  An unsigned 8 bit number, read with strtoul() .
  size_t
  An unsigned number with size_t limitations, read with strtoul .
  sockname
  A socket address. See address−option ‘bind’
  string
  A sequence of characters, not containing ’\0’ and, depending on the
  position within the command line, ’:’, ’,’, or "!!". Note that you
  might have to escape shell meta characters in the command line.
  TCP service
  A service name, not starting with a digit, that is resolved by
  getservbyname() , or an unsigned int 16 bit number read with strtoul()
  .
  timeval
  A double float specifying seconds; the number is mapped into a struct
  timeval, consisting of seconds and microseconds.
  timespec
  A double float specifying seconds; the number is mapped into a struct
  timespec, consisting of seconds and nanoseconds.
  UDP service
  A service name, not starting with a digit, that is resolved by
  getservbyname() , or an unsigned int 16 bit number read with strtoul()
  .
  unsigned int
  A number read with strtoul() . The value must fit into a C unsigned
  int.
  user
  If the first character is a decimal digit, the value is read with
  strtoul() as unsigned integer specifying a user id. Otherwise, it must
  be an existing user name.

EXAMPLES

  socat − TCP4:www.domain.org:80
  transfers data between STDIO (−) and a TCP4 connection to port 80 of
  host www.domain.org. This example results in an interactive connection
  similar to telnet or netcat. The stdin terminal parameters are not
  changed, so you may close the relay with ^D or abort it with ^C.
  socat -d -d READLINE,history=$HOME/.http_history \
  TCP4:www.domain.org:www,crnl
  this is similar to the previous example, but you can edit the current
  line in a bash like manner (READLINE) and use the history file
  .http_history; socat prints messages about progress (−d −d). The port
  is specified by service name (www), and correct network line
  termination characters (crnl) instead of NL are used.
  socat TCP4−LISTEN:www TCP4:www.domain.org:www
  installs a simple TCP port forwarder. With TCP4−LISTEN it listens on
  local port "www" until a connection comes in, accepts it, then connects
  to the remote host (TCP4) and starts data transfer. It will not accept
  a econd connection.
  socat -d -d -lmlocal2 \
  TCP4-LISTEN:80,bind=myaddr1,reuseaddr,fork,su=nobody,range=10.0.0.0/8 \
  TCP4:www.domain.org:80,bind=myaddr2
  TCP port forwarder, each side bound to another local IP address (bind).
  This example handles an almost arbitrary number of parallel or
  consecutive connections by fork’ing a new process after each accept() .
  It provides a little security by su’ing to user nobody after forking;
  it only permits connections from the private 10 network (range); due to
  reuseaddr, it allows immediate restart after master process’s
  termination, even if some child sockets are not completely shut down.
  With −lmlocal2, socat logs to stderr until successfully reaching the
  accept loop. Further logging is directed to syslog with facility
  local2.
  socat TCP4-LISTEN:5555,fork,tcpwrap=script \
  EXEC:/bin/myscript,chroot=/home/sandbox,su-d=sandbox,pty,stderr
  a simple server that accepts connections (TCP4−LISTEN) and fork’s a new
  child process for each connection; every child acts as single relay.
  The client must match the rules for daemon process name "script" in
  /etc/hosts.allow and /etc/hosts.deny, otherwise it is refused access
  (see "man 5 hosts_access"). For EXEC’uting the program, the child
  process chroot’s to /home/sandbox, su’s to user sandbox, and then
  starts the program /home/sandbox/bin/myscript. Socat and myscript
  communicate via a pseudo tty (pty); myscript’s stderr is redirected to
  stdout, so its error messages are transferred via socat to the
  connected client.
  socat EXEC:"mail.sh target@domain.com",fdin=3,fdout=4 \
  TCP4:mail.relay.org:25,crnl,bind=alias1.server.org,mss=512
  mail.sh is a shell script, distributed with socat, that implements a
  simple SMTP client. It is programmed to "speak" SMTP on its FDs 3 (in)
  and 4 (out). The fdin and fdout options tell socat to use these FDs for
  communication with the program. Because mail.sh inherits stdin and
  stdout while socat does not use them, the script can read a mail body
  from stdin. Socat makes alias1 your local source address (bind), cares
  for correct network line termination (crnl) and sends at most 512 data
  bytes per packet (mss).
  socat −,escape=0x0f /dev/ttyS0,rawer,crnl
  opens an interactive connection via the serial line, e.g. for talking
  with a modem. rawer sets the console’s and ttyS0’s terminal parameters
  to practicable values, crnl converts to correct newline characters.
  escape allows to terminate the socat process with character control−O.
  Consider using READLINE instead of the first address.
  socat UNIX-LISTEN:/tmp/.X11-unix/X1,fork \
  SOCKS4:host.victim.org:127.0.0.1:6000,socksuser=nobody,sourceport=20
  with UNIX−LISTEN, socat opens a listening UNIX domain socket
  /tmp/.X11−unix/X1. This path corresponds to local XWindow display :1 on
  your machine, so XWindow client connections to DISPLAY=:1 are accepted.
  Socat then speaks with the SOCKS4 server host.victim.org that might
  permit sourceport 20 based connections due to an FTP related weakness
  in its static IP filters. Socat pretends to be invoked by socksuser
  nobody, and requests to be connected to loopback port 6000 (only weak
  sockd configurations will allow this). So we get a connection to the
  victims XWindow server and, if it does not require MIT cookies or
  Kerberos authentication, we can start work. Please note that there can
  only be one connection at a time, because TCP can establish only one
  session with a given set of addresses and ports.
  socat −u /tmp/readdata,seek−end=0,ignoreeof −
  this is an example for unidirectional data transfer (−u). Socat
  transfers data from file /tmp/readdata (implicit address GOPEN),
  starting at its current end (seek−end=0 lets socat start reading at
  current end of file; use seek=0 or no seek option to first read the
  existing data) in a "tail −f" like mode (ignoreeof). The "file" might
  also be a listening UNIX domain socket (do not use a seek option then).
  (sleep 5; echo PASSWORD; sleep 5; echo ls; sleep 1) |
  socat - EXEC:’ssh -l user server’,pty,setsid,ctty
  EXEC’utes an ssh session to server. Uses a pty for communication
  between socat and ssh, makes it ssh’s controlling tty (ctty), and makes
  this pty the owner of a new process group (setsid), so ssh accepts the
  password from socat.
  socat -u TCP4-LISTEN:3334,reuseaddr,fork \
  OPEN:/tmp/in.log,creat,append
  implements a simple network based message collector. For each client
  connecting to port 3334, a new child process is generated (option
  fork). All data sent by the clients are append’ed to the file
  /tmp/in.log. If the file does not exist, socat creat’s it. Option
  reuseaddr allows immediate restart of the server process.
  socat READLINE,noecho=’[Pp]assword:’ EXEC:’ftp
  ftp.server.com’,pty,setsid,ctty
  wraps a command line history (READLINE) around the EXEC’uted ftp client
  utility. This allows editing and reuse of FTP commands for relatively
  comfortable browsing through the ftp directory hierarchy. The password
  is echoed! pty is required to have ftp issue a prompt. Nevertheless,
  there may occur some confusion with the password and FTP prompts.
  socat PTY,link=$HOME/dev/vmodem0,rawer,wait-slave \
  EXEC:"ssh modemserver.us.org socat - /dev/ttyS0,nonblock,rawer"
  generates a pseudo terminal device (PTY) on the client that can be
  reached under the symbolic link $HOME/dev/vmodem0. An application that
  expects a serial line or modem can be configured to use
  $HOME/dev/vmodem0; its traffic will be directed to a modemserver via
  ssh where another socat instance links it to /dev/ttyS0.
  socat TCP4-LISTEN:2022,reuseaddr,fork \
  PROXY:proxy:www.domain.org:22,proxyport=3128,proxyauth=user:pass
  starts a forwarder that accepts connections on port 2022, and directs
  them through the proxy daemon listening on port 3128 (proxyport) on
  host proxy, using the CONNECT method, where they are authenticated as
  "user" with "pass" (proxyauth). The proxy should establish connections
  to host www.domain.org on port 22 then.
  socat − SSL:server:4443,cafile=server.crt,cert=client.pem
  is an OpenSSL client that tries to establish a secure connection to an
  SSL server. Option cafile specifies a file that contains trust
  certificates: we trust the server only when it presents one of these
  certificates and proofs that it owns the related private key. Otherwise
  the connection is terminated. With cert a file containing the client
  certificate and the associated private key is specified. This is
  required in case the server wishes a client authentication; many
  Internet servers do not.
  The first address (’−’) can be replaced by almost any other socat
  address.
  socat
  SSL−LISTEN:4443,reuseaddr,pf=ip4,fork,cert=server.pem,cafile=client.crt
  PIPE
  is an OpenSSL server that accepts TCP connections, presents the
  certificate from the file server.pem and forces the client to present a
  certificate that is verified against cafile.crt.
  The second address (’PIPE’) can be replaced by almost any other socat
  address.
  For instructions on generating and distributing OpenSSL keys and
  certificates see the additional socat docu socat−openssl.txt.
  echo |socat −u − file:/tmp/bigfile,create,largefile,seek=100000000000
  creates a 100GB sparse file; this requires a file system type that
  supports this (ext2, ext3, reiserfs, jfs; not minix, vfat). The
  operation of writing 1 byte might take long (reiserfs: some minutes;
  ext2: "no" time), and the resulting file can consume some disk space
  with just its inodes (reiserfs: 2MB; ext2: 16KB).
  socat tcp−l:7777,reuseaddr,fork system:’filan −i 0 −s >&2’,nofork
  listens for incoming TCP connections on port 7777. For each accepted
  connection, invokes a shell. This shell has its stdin and stdout
  directly connected to the TCP socket (nofork). The shell starts filan
  and lets it print the socket addresses to stderr (your terminal
  window).
  echo −e "\0\14\0\0\c" |socat −u −
  file:/usr/bin/squid.exe,seek=0x00074420
  functions as primitive binary editor: it writes the 4 bytes 000 014 000
  000 to the executable /usr/bin/squid at offset 0x00074420 (this is a
  real world patch to make the squid executable from Cygwin run under
  Windows, actual per May 2004).
  socat − tcp:www.blackhat.org:31337,readbytes=1000
  connects to an unknown service and prevents being flooded.
  socat −U TCP:target:9999,end−close TCP−L:8888,reuseaddr,fork
  merges data arriving from different TCP streams on port 8888 to just
  one stream to target:9999. The end−close option prevents the child
  processes forked off by the second address from terminating the shared
  connection to 9999 (close\(2) just unlinks the inode which stays active
  as long as the parent process lives; shutdown\(2) would actively
  terminate the connection).
  socat −
  UDP4−DATAGRAM:192.168.1.0:123,sp=123,broadcast,range=192.168.1.0/24
  sends a broadcast to the network 192.168.1.0/24 and receives the
  replies of the timeservers there. Ignores NTP packets from hosts
  outside this network.
  socat −
  SOCKET−DATAGRAM:2:2:17:x007bxc0a80100x0000000000000000,bind=x007bx00000
  000x0000000000000000,setsockopt−int=1:6:1,range=x0000xc0a80100x00000000
  00000000:x0000xffffff00x0000000000000000
  is semantically equivalent to the previous example, but all parameters
  are specified in generic form. the value 6 of setsockopt−int is the
  Linux value for SO_BROADCAST.
  socat − IP4−DATAGRAM:255.255.255.255:44,broadcast,range=10.0.0.0/8
  sends a broadcast to the local network\(s) using protocol 44. Accepts
  replies from the private address range only.
  socat −
  UDP4−DATAGRAM:224.255.0.1:6666,bind=:6666,ip−add−membership=224.255.0.1
  :eth0
  transfers data from stdin to the specified multicast address using UDP.
  Both local and remote ports are 6666. Tells the interface eth0 to also
  accept multicast packets of the given group. Multiple hosts on the
  local network can run this command, so all data sent by any of the
  hosts will be received by all the other ones. Note that there are many
  possible reasons for failure, including IP−filters, routing issues,
  wrong interface selection by the operating system, bridges, or a badly
  configured switch.
  socat TCP:host2:4443 TUN:192.168.255.1/24,up
  establishes one side of a virtual (but not private!) network with host2
  where a similar process might run, with UDP−L and tun address
  192.168.255.2. They can reach each other using the addresses
  192.168.255.1 and 192.168.255.2. Note that streaming eg. via TCP or SSL
  does not guarantee to retain packet boundaries and may thus cause
  packet loss.
  socat PTY,link=/var/run/ppp,rawer INTERFACE:hdlc0
  circumvents the problem that pppd requires a serial device and thus
  might not be able to work on a synchronous line that is represented by
  a network device. socat creates a PTY to make pppd happy, binds to the
  network interface hdlc0, and can transfer data between both devices.
  Use pppd on device /var/run/ppp then.
  socat −T 1 −d −d TCP−L:10081,reuseaddr,fork,crlf SYSTEM:"echo −e
  \"\\\"HTTP/1.0 200 OK\\\nDocumentType: text/plain\\\n\\\ndate:
  \$\(date\)\\\nserver:\$SOCAT_SOCKADDR:\$SOCAT_SOCKPORT\\\nclient:
  \$SOCAT_PEERADDR:\$SOCAT_PEERPORT\\\n\\\"\"; cat; echo −e
  \"\\\"\\\n\\\"\""
  creates a simple HTTP echo server: each HTTP client that connects gets
  a valid HTTP reply that contains information about the client address
  and port as it is seen by the server host, the host address (which
  might vary on multihomed servers), and the original client request.
  socat −d −d
  UDP4−RECVFROM:9999,so−broadcast,so−timestamp,ip−pktinfo,ip−recverr,ip−r
  ecvopts,ip−recvtos,ip−recvttl!!−
  SYSTEM:’export; sleep 1’ |grep SOCAT
  waits for an incoming UDP packet on port 9999 and prints the
  environment variables provided by socat. On BSD based systems you have
  to replace ip−pktinfo with ip−recvdstaddr,ip−recvif. Especially
  interesting is SOCAT_IP_DSTADDR: it contains the target address of the
  packet which may be a unicast, multicast, or broadcast address.

DIAGNOSTICS

  Socat uses a logging mechanism that allows to filter messages by
  severity. The severities provided are more or less compatible to the
  appropriate syslog priority. With one or up to four occurrences of the
  −d command line option, the lowest priority of messages that are issued
  can be selected. Each message contains a single uppercase character
  specifying the messages severity (one of F, E, W, N, I, or D)
  FATAL:
  Conditions that require unconditional and immediate program
  termination.
  ERROR:
  Conditions that prevent proper program processing. Usually the program
  is terminated (see option −s).
  WARNING:
  Something did not function correctly or is in a state where correct
  further processing cannot be guaranteed, but might be possible.
  NOTICE:
  Interesting actions of the program, e.g. for supervising socat in some
  kind of server mode.
  INFO:
  Description of what the program does, and maybe why it happens. Allows
  to monitor the lifecycles of file descriptors.
  DEBUG:
  Description of how the program works, all system or library calls and
  their results.
  Log messages can be written to stderr, to a file, or to syslog.
  On exit, socat gives status 0 if it terminated due to EOF or inactivity
  timeout, with a positive value on error, and with a negative value on
  fatal error.

FILES

  /usr/bin/socat
  /usr/bin/filan
  /usr/bin/procan

ENVIRONMENT VARIABLES

  Input variables carry information from the environment to socat, output
  variables are set by socat for use in executed scripts and programs.
  In the output variables beginning with "SOCAT" this prefix is actually
  replaced by the upper case name of the executable or the value of
  option −lp.
  SOCAT_DEFAULT_LISTEN_IP (input)
  (Values 4 or 6) Sets the IP version to be used for listen, recv, and
  recvfrom addresses if no pf (protocol−family) option is given. Is
  overridden by socat options −4 or −6.
  SOCAT_PREFERRED_RESOLVE_IP (input)
  (Values 0, 4, or 6) Sets the IP version to be used when resolving
  target host names when version is not specified by address type, option
  pf (protocol−family), or address format. If name resolution does not
  return a matching entry, the first result (with differing IP version)
  is taken. With value 0, socat always selects the first record and its
  IP version.
  SOCAT_FORK_WAIT (input)
  Specifies the time (seconds) to sleep the parent and child processes
  after successful fork\(). Useful for debugging.
  SOCAT_VERSION (output)
  Socat sets this variable to its version string, e.g. "1.7.0.0" for
  released versions or e.g. "1.6.0.1+envvar" for temporary versions; can
  be used in scripts invoked by socat.
  SOCAT_PID (output)
  Socat sets this variable to its process id. In case of fork address
  option, SOCAT_PID gets the child processes id. Forking for exec and
  system does not change SOCAT_PID.
  SOCAT_PPID (output)
  Socat sets this variable to its process id. In case of fork, SOCAT_PPID
  keeps the pid of the master process.
  SOCAT_PEERADDR (output)
  With passive socket addresses (all LISTEN and RECVFROM addresses), this
  variable is set to a string describing the peers socket address. Port
  information is not included.
  SOCAT_PEERPORT (output)
  With appropriate passive socket addresses (TCP, UDP, and SCTP − LISTEN
  and RECVFROM), this variable is set to a string containing the number
  of the peer port.
  SOCAT_SOCKADDR (output)
  With all LISTEN addresses, this variable is set to a string describing
  the local socket address. Port information is not included example
  SOCAT_SOCKPORT (output)
  With TCP−LISTEN, UDP−LISTEN, and SCTP−LISTEN addresses, this variable
  is set to the local port.
  SOCAT_TIMESTAMP (output)
  With all RECVFROM addresses where address option so−timestamp is
  applied, socat sets this variable to the resulting timestamp.
  SOCAT_IP_OPTIONS (output)
  With all IPv4 based RECVFROM addresses where address option ip−recvopts
  is applied, socat fills this variable with the IP options of the
  received packet.
  SOCAT_IP_DSTADDR (output)
  With all IPv4 based RECVFROM addresses where address option
  ip−recvdstaddr (BSD) or ip−pktinfo (other platforms) is applied, socat
  sets this variable to the destination address of the received packet.
  This is particularly useful to identify broadcast and multicast
  addressed packets.
  SOCAT_IP_IF (output)
  With all IPv4 based RECVFROM addresses where address option ip−recvif
  (BSD) or ip−pktinfo (other platforms) is applied, socat sets this
  variable to the name of the interface where the packet was received.
  SOCAT_IP_LOCADDR (output)
  With all IPv4 based RECVFROM addresses where address option ip−pktinfo
  is applied, socat sets this variable to the address of the interface
  where the packet was received.
  SOCAT_IP_TOS (output)
  With all IPv4 based RECVFROM addresses where address option ip−recvtos
  is applied, socat sets this variable to the TOS (type of service) of
  the received packet.
  SOCAT_IP_TTL (output)
  With all IPv4 based RECVFROM addresses where address option ip−recvttl
  is applied, socat sets this variable to the TTL (time to live) of the
  received packet.
  SOCAT_IPV6_HOPLIMIT (output)
  With all IPv6 based RECVFROM addresses where address option
  ipv6−recvhoplimit is applied, socat sets this variable to the hoplimit
  value of the received packet.
  SOCAT_IPV6_DSTADDR (output)
  With all IPv6 based RECVFROM addresses where address option
  ipv6−recvpktinfo is applied, socat sets this variable to the
  destination address of the received packet.
  SOCAT_IPV6_TCLASS (output)
  With all IPv6 based RECVFROM addresses where address option
  ipv6−recvtclass is applied, socat sets this variable to the transfer
  class of the received packet.
  SOCAT_OPENSSL_X509_ISSUER (output)
  Issuer field from peer certificate
  SOCAT_OPENSSL_X509_SUBJECT (output)
  Subject field from peer certificate
  SOCAT_OPENSSL_X509_COMMONNAME (output)
  commonName entries from peer certificates subject. Multiple values are
  separated by " // ".
  SOCAT_OPENSSL_X509_* (output)
  all other entries from peer certificates subject
  SOCAT_OPENSSL_X509V3_DNS (output)
  DNS entries from peer certificates extensions − subjectAltName field.
  Multiple values are separated by " // ".
  HOSTNAME (input)
  Is used to determine the hostname for logging (see −lh).
  LOGNAME (input)
  Is used as name for the socks client user name if no socksuser is
  given.
  With options su and su−d, LOGNAME is set to the given user name.
  USER (input)
  Is used as name for the socks client user name if no socksuser is given
  and LOGNAME is empty.
  With options su and su−d, USER is set to the given user name.
  SHELL (output)
  With options su and su−d, SHELL is set to the login shell of the given
  user.
  PATH (output)
  Can be set with option path for exec and system addresses.
  HOME (output)
  With options su and su−d, HOME is set to the home directory of the
  given user.

CREDITS

  The work of the following groups and organizations was invaluable for
  this project:
  The FSF (GNU, http://www.fsf.org/ project with their free and portable
  development software and lots of other useful tools and libraries.
  The Linux developers community (http://www.linux.org/) for providing a
  free, open source operating system.
  The Open Group (http://www.unix−systems.org/) for making their standard
  specifications available on the Internet for free.

VERSION

  This man page describes version 1.7.3 of socat.

BUGS

  Addresses cannot be nested, so a single socat process cannot, e.g.,
  drive ssl over socks.
  Address option ftruncate without value uses default 1 instead of 0.
  Verbose modes (−x and/or −v) display line termination characters
  inconsistently when address options cr or crnl are used: They show the
  data after conversion in either direction.
  The data transfer blocksize setting (−b) is ignored with address
  readline.
  Send bug reports to <socat@dest−unreach.org>

SEE ALSO

  nc\(1), netcat6\(1), sock\(1), rinetd\(8), cage\(1), socks.conf\(5),
  openssl\(1), stunnel\(8), pty\(1), rlwrap\(1), setsid\(1)
  Socat home page http://www.dest−unreach.org/socat/

AUTHOR

  Gerhard Rieger <rieger@dest−unreach.org>

ser2net

Ser2net ist OpenSource und steht unter https://sourceforge.net/projects/ser2net/files/ser2net/ zum Download zur Verfügung.

README der Version 3.5 vom 2017-11-22 (kommentiert)

This is ser2net, a program for allowing network connections to serial ports or IMPI (Intelligent Platform Monitoring Interface allow you to manage a server remotely.) Serial Over Lan ( SOL) connections. See the man page for information about using the program.

Note that ser2net supports RFC2217 (remote control of serial port parameters), but you must have a compliant client. The only one I know of is kermit.

ser2net supports making connections to IPMI SOL (serial over LAN) capable systems. This way, if you have a system with SOL, you can use it with programs that speak sockets and avoid having to run a serial cable to the system. It uses OpenIPMI for this, so you have to know how to make an OpenIPMI connection to the remote system. That can be rather complicated, but for a simple example, add a line like:

 3022:telnet:0:sol.lan -U <userid> -P <password> <ipmi BMC IP>:115200

Obviously, use the IPMI BMC userid and password here. Depending on your system there are a lot of other options, and configuration of IPMI on the remote system is not for the faint of heart. And also, if you put passwords in the ser2net.conf file, it becomes a security issue and you should make it readable only by the user that runs ser2net.

ser2net also supports threading. By default it runs with a single thread but you can add '-t <num threads>' and it will spawn the given number of threads. On modern Linux systems it uses epoll to avoid the "thundering herd" issue, so it should be quite scalable. Also, it runs reconfigurations in a separate thread to avoid a reconfig blocking things up.

If you don't want to compile with threads, you can add "--with-pthreads=no" to the configure line.

If you want the opposite of ser2net (you want to connect to a "local" serial port device that is really remote) then Cyclades has provided a tool for this at https://sourceforge.net/projects/cyclades-serial/. It is capable of connecting to ser2net using RFC2217.

If you check this out from git, you won't have all the configure programs and files, because those are generated. Do:

  autoreconf -i

to generate everything first. Then you can run configure.

NAME

  ser2net − Serial to network proxy

SYNOPSIS

(Zusammenfassung)

  ser2net [−c configfile] [−C configline] [−p controlport] [−n] [−d] [−b] [−v] [-P pidfile]

DESCRIPTION

  The ser2net daemon allows telnet and tcp sessions to be established
  with a unit’s serial ports.
  The program comes up normally as a daemon, opens the TCP ports
  specified in the configuration file, and waits for connections. Once a
  connection occurs, the program attempts to set up the connection and
  open the serial port. If another user is already using the connection
  or serial port, the connection is refused with an error message.

OPTIONS

Nr. Option Originaltext Übersetzung/Erläuterung
1 −c config−file Set the configuration file to one other than the default of /etc/ser2net.conf Beispiel
2 −C config-line Handle a single configuration line. This may be specified multiple times for multiple lines. This is just like a line in the config file. This disables the default config file, you must specify a -c after the last -C to have it read a config file, too. Beispiel
3 -n Stops the daemon from forking and detaching from the controlling terminal. This is useful for running from init. Beispiel
4 -d Like -n, but also sends the system logs to standard output. This is most useful for debugging purposes. Beispiel
5 -P pidfile If specified, put the process id (pid) of ser2net in the pidfile, replacing whatever was in that file previously. A pidfile is not created by default, you must specify this to create one. Note also that this filename must be specific with the full path, as ser2net will change directory to "/" when it becomes a daemon. when it Beispiel
6 -u If UUCP locking is enabled, this will disable the use of UUCP locks. Beispiel
7 -b Cisco IOS uses a different mechanism for specifying the baud rates than the mechanism described in RFC2217. This option sets the IOS version of setting the baud rates. The default is RFC2217’s. Note that this capability is now handled automatically and this option is ignored. Beispiel
8 -v Prints the version of the program and exits. Beispiel
9 −p controlport Enables the control port and sets the TCP port to listen to for the control port. A port number may be of the form [host,]port, such as 127.0.0.1,2000 or localhost,2000. If this is specified, it will only bind to the IP address specified for the port. Otherwise, it will bind to all the addresses on the machine. If the port number is zero, that means that standard in/out will be used for the only input/output, and only one port should be specified in the config. This way, it can be used from inetd. Beispiel
10 −s signature Specifies the default RFC2217 signature. Beispiel

CONTROL PORT

The control port provides a simple interface for controlling the ports and viewing their status. To accomplish this, it has the following commands:

  showport [<TCP port>]
  Show information about a port. If no port is given, all ports are
  displayed.
  showshortport [<TCP port>]
  Show information about a port, each port on one line. If no port is
  given, all ports are displayed. This can produce very wide output.
  help
  Display a short list and summary of commands.
  exit
  Disconnect from the control port.
  version
  Display the version of this program.
  monitor <type> <tcp port>
  Display all the input for a given port on the calling control port.
  Only one direction may be monitored at a time. The type field may be
  tcp or term and specifies whether to monitor data from the TCP port or
  from the serial port Note that data monitoring is best effort, if the
  controller port cannot keep up the data will be silently dropped. A
  controller may only monitor one thing and a port may only be monitored
  by one controller.
  monitor stop
  Stop the current monitor.
  disconnect <tcp port>
  Disconnect the tcp connection on the port.
  setporttimeout <tcp port> <timeout>
  Set the amount of time in seconds before the port connection will be
  shut down if no activity has been seen on the port.
  setportconfig <tcp port> <config>
  Set the port configuration as in the device configuration in the
  /etc/ser2net.conf file. If conflicting options are specified, the last
  option will be the one used. Note that these will not change until the
  port is disconnected and connected again. Options 300, 1200, 2400,
  4800, 9600, 19200, 38400, 57600, 115200 set the various baud rates.
  EVEN, ODD, NONE set the parity. 1STOPBIT, 2STOPBITS set the number of
  stop bits. 7DATABITS, 8DATABITS set the number of data bits. [-]XONXOFF
  turns on (- off) XON/XOFF support. [-]RTSCTS turns on (- off) hardware
  flow control. [-]LOCAL ignores (- checks) the modem control lines (DCD,
  DTR, etc.)
  setportcontrol <tcp port> <controls>
  Modify dynamic port controls. These do not stay between connections.
  Controls are: DTRHI, DTRLO Turns on and off the DTR line. RTSHI, RTSLO
  Turns on and off the RTS line.
  setportenable <tcp port> <enable state>
  Sets the port operation state. Valid states are: off to shut the TCP
  port down, raw to enable the TCP port transfer all I/O as-is, rawlp to
  enable the TCP port input and device output without termios setting,
  and telnet to enable the TCP port is up run the telnet negotiation
  protocol on the port.

CONFIGURATION

Configuration is accomplished through the file /etc/ser2net.conf. A file with another name or path may be specified using the −c option, or individual config lines may be specified with the −C option. This file consists of one or more entries with the following format:

  <TCP port>:<state>:<timeout>:<device>:<options>

or

  BANNER:<banner name>:<banner text>

or

  SIGNATURE:<signature name>:<signature text>

or

  OPENSTR:<openstr name>:<openstr text>

or

  CLOSESTR:<closestr name>:<closestr text>

or

  TRACEFILE:<tracefile name>:<tracefile>

or

  CONTROLPORT:<port spec>

FIELDS

  TCP port
  Name or number of the TCP/IP port to accept connections from for this
  device. A port number may be of the form 
  [host,]port, such as 127.0.0.1,2000 or localhost,2000, or ::,2000. 
  If this is specified, it will only bind to the IP address specified for the port. 
  Otherwise, it will bind to all the ports on the machine. 
  You can specify an IPV6 address in the port, any colon before the comma is ignored for parsing fields.
  state
  Either raw or rawlp or telnet or off. 
  off disables the port from accepting connections. 
  It can be turned on later from the control port.
  raw enables the port and transfers all data as-is between the port and
  the long. rawlp enables the port and transfers all input data to
  device, device is open without any termios setting. It allow to use
  /dev/lpX devices and printers connected to them. telnet enables the
  port and runs the telnet protocol on the port to set up telnet
  parameters. This is most useful for using telnet.
  timeout
  The time (in seconds) before the port will be disconnected if there is
  no activity on it. A zero value disables this function.
  device
  The name of the device to connect to. This must be in the form of
  /dev/<device>.
  device configuration options
  Sets operational parameters for the serial port. 
  Values may be separated by spaces or commas. 
  Options
  * 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 set the various baud rates. 
  * EVEN, ODD, NONE set the parity. 
  * 1STOPBIT, 2STOPBITS set the number of stop bits.
  * 7DATABITS, 8DATABITS set the number of data bits. 
  * [-]XONXOFF turns on (- off) XON/XOFF support. 
  * [-]RTSCTS turns on (- off) hardware flow control. 
  * [-]LOCAL ignores (- checks) the modem control lines (DCD, DTR, etc.) 
  * [-]HANGUP_WHEN_DONE lowers (- does not lower) the modem control lines (DCD, DTR, etc.) when the connection closes. 
  * NOBREAK disables automatic clearing of the break setting of the port. 
  HINT: A serial break is not a character. It is a signal that can be sent using the TX line of the device sending the break.
  When a serial port is idle and no data is being sent the TX line is in a logical 1 state. While data is being send the TX line rapidly transitions between logical 0 and logical 1. 
  Each frame of data takes a certain period of time to send, depending on the bit rate of the connection. This is called the "frame time" or "word time".
  A break occurs when the TX line is held to a logical 0 for longer than one frame time.
  There are short breaks and long breaks. In general a short break is one that lasts longer than one frame time, but less than two frame times. A long break can last two or more frame times. 
  Most serial devices that support breaks use a short break.
  * remctl allows remote control of the serial port parameters via RFC 2217. See the README for more info. 
  * kickolduser sets the port so that the previous user will be kicked off if a new user comes in. Useful if you forget to log off from someplace else a lot. 
  * <banner name> displays the given banner when a user connects to the port. 
  * <signature name> sends RFC 2217 signature on clients request. 
  * <openstr name> Send the given string to the device when the port is opened. 
  * <closestr name> Send the given string to the device when the port is closed.
  * tr=<filename> When the port is opened, open the given tracefile and
  store all data read from the physical device (and thus written to the
  user’s TCP port) in the file. The actual filename is specified in the
  TRACEFILE directive. If the file already exists, it is appended. The
  file is closed when the port is closed.
  * tw=<filename> Like tr, but traces data written to the device.
  * tb=<filename> trace both read and written data to the same file. Note
  that this is independent of tr and tw, so you may be tracing read,
  write, and both to different files.
  * [-]hexdump turns on (- turns off) hexdump output to all trace files.
  Each line in the trace file will be 8 (or less) bytes in canonical
  hex+ASCII format. This is useful for debugging a binary protocol.
  * [-]timestamp adds (- removes) a timestamp to all of the trace files. A
  timestamp is prepended to each line if hexdump is active for the trace
  file. A timestamped line is also recorded in the trace file when a
  remote client connects or disconnects from the port.
  * [-][tr-|tw-|tb-]hexdump turns on (- turns off) hexdump output for only
  one trace file. May be combined with [-]hexdump. Order is important.
  * [-][tr-|tw-|tb-]timestamp adds (- removes) a timestamp to only one the
  trace files May be combined with [-]timestamp. Order is important.
  banner name
  A name for the banner; this may be used in the options of a port.
  banner text
  The text to display as the banner. It takes escape sequences for
  substituting strings, see "FILENAME, BANNER, AND STRING FORMATTING" for
  details.
  tracefile name
  A name for the tracefile, this is used in the tw, tr, and tb options of
  a port.
  tracefile
  The file to send the trace into. Note that this takes escape sequences
  for substituting strings, see "FILENAME, BANNER, AND STRING FORMATTING"
  for details. Note that when using the time escape sequences, the time
  is read once at port startup, so if you use both tw and tr they will
  have the same date and time.
  port spec
  The control port specification as defined by the [−p] option on the
  command line. This lets the control port be specified in the
  configuration file. The command line will override this, and only the
  first port specified is used.
  Blank lines and lines starting with ‘#’ are ignored.

FILENAME, BANNER, AND STRING FORMATTING

  Filenames, banners, and open/close string may contain normal "C" escape
  sequences and a large number of other escape sequences, too:
  \a - bell
  \b - backspace
  \f - form feed
  \n - newline
  \r - carriage return
  \t - tab
  \v - vertical tab
  \\ - \
  \? - ?
  \’ - ’
  \" - "
  \nnn - octal value for nnn
  \xXX - hex value for XX
  \d - The device name (/dev/ttyS0, etc.)
  \p - TCP port number
  \B - The serial port parameters (eg 9600N81)
  \Y -> year
  \y -> day of the year (days since Jan 1)
  \M -> month (Jan, Feb, Mar, etc.)
  \m -> month (as a number)
  \A -> day of the week (Mon, Tue, etc.)
  \D -> day of the month
  \e -> epoc (seconds since Jan 1, 1970)
  \U -> microseconds in the current second
  \p -> local port number
  \d -> local device name
  \I -> remote IP address (in dot format)
  \H -> hour (24-hour time)
  \h -> hour (12-hour time)
  \i -> minute
  \S -> second
  \q -> am/pm
  \P -> AM/PM
  In addition, for backwards compatibility because filenames and banners
  used to have different formatting, \s is the serial port parameters if
  in a banner and seconds if in a filename. Use of this is discouraged as
  it may change in the future.
  These sequences may be used to make the filename unique per open and
  identify which port/device the filename was for. Note that in filenames
  when using \d, everything up to and including last / in the device name
  is removed, because you can’t have a / in a filename. So in a filename
  /dev/ttyS0 would become just ttyS0.

SECURITY

  ser2net uses the tcp wrappers interface to implement host-based
  security. See hosts_access(5) for a description of the file setup. Two
  daemons are used by ser2net, "ser2net" is for the data ports and
  "ser2net-control" is for the control ports.

SIGNALS

  SIGHUP
  If ser2net receives a SIGHUP, it will reread it configuration file and
  make the appropriate changes. If an inuse port is changed or deleted,
  the actual change will not occur until the port is disconnected.

Error

  Almost all error output goes to syslog, not standard output.

FILES

  /etc/ser2net.conf

SEE ALSO

  telnet(1), hosts_access(5)

KNOWN PROBLEMS

  None.

AUTHOR

  Corey Minyard <minyard@acm.org>

nc (netcat)

NAME

  nc — arbitrary TCP and UDP connections and listens

nc oder netcat (oft nur ein Link/Verknüpfung auf nc) ist ein Programm mit dem man nach Belieben, Verbindungen oder einfach nur "Zuhörer" für TCP oder UDP realisieren kann.

SYNOPSIS

(Zusammenfassung)

  nc [−46DdhklnrStUuvzC] [−i interval] [−P proxy_username] [−p source_port] [−s source_ip_address] [−T ToS] [−w timeout] [−X proxy_protocol] [−x proxy_address[:port]] [hostname] [port[s]]

Aus der Syntax kann man erkennen, dass sich (ohne Fehlermeldung) nc gänzlich ohne Parameter aufrufen lässt. Es wird in diesem Fall ggf. folgender Hinweis ausgegeben:

This is nc from the netcat-openbsd package. An alternative nc is available in the netcat-traditional package.

DESCRIPTION

  The nc (or netcat) utility is used for just about anything under the
  sun involving TCP or UDP. It can open TCP connections, send UDP
  packets, listen on arbitrary TCP and UDP ports, do port scanning, and
  deal with both IPv4 and IPv6. Unlike telnet(1), nc scripts nicely, and
  separates error messages onto standard error instead of sending them to
  standard output, as telnet(1) does with some.
  Common uses include:
   * simple TCP proxies
   * shell-script based HTTP clients and servers
   * network daemon testing
   * a SOCKS or HTTP ProxyCommand for ssh(1)
   * and much, much more

OPTIONS

  The 25 options are as follows:


Überschrift Überschrift Überschrift
1 -4 Forces nc to use IPv4 addresses only.
2 -6 Forces nc to use IPv6 addresses only.
3 -D Enable debugging on the socket.
4 -d Do not attempt to read from stdin.
5 -h Prints out nc help.
6 -i interval Specifies a delay time interval between lines of text sent and received. Also causes a delay time between connections to multiple ports.
7 -k Forces nc to stay listening for another connection after its current connection is completed. It is an error to use this option without the −l option.
8 -l Used to specify that nc should listen for an incoming connection rather than initiate a connection to a remote host. It is an error to use this option in conjunction with the −p, −s, or −z options. Additionally, any timeouts specified with the −w option are ignored.
9 -n Do not do any DNS or service lookups on any specified addresses, hostnames or ports.
10 −P proxy_username Specifies a username to present to a proxy server that requires authentication. If no username is specified then authentication will not be attempted. Proxy authentication is only supported for HTTP CONNECT proxies at present.
11 −p source_port Specifies the source port nc should use, subject to privilege restrictions and availability. It is an error to use this option in conjunction with the −l option.
12 -q after EOF on stdin, wait the specified number of seconds and then quit. If seconds is negative, wait forever.
13 -r Specifies that source and/or destination ports should be chosen randomly instead of sequentially within a range or in the order that the system assigns them.
14 -S Enables the RFC 2385 TCP MD5 signature option.
15 −s source_ip_address Specifies the IP of the interface which is used to send the packets. It is an error to use this option in conjunction with the −l option.
16 −T ToS Specifies IP Type of Service (ToS) for the connection. Valid values are the tokens ‘‘lowdelay’’, ‘‘throughput’’, ‘‘reliability’’, or an 8-bit hexadecimal value preceded by ‘‘0x’’.
17 -C Send CRLF as line-ending
18 -t Causes nc to send RFC 854 DON’T and WON’T responses to RFC 854 DO and WILL requests. This makes it possible to use nc to script telnet sessions.
19 -U Specifies to use Unix Domain Sockets.
20 -u Use UDP instead of the default option of TCP.
21 -v Have nc give more verbose output.
22 −w timeout If a connection and stdin are idle for more than timeout seconds, then the connection is silently closed. The −w flag has no effect on the −l option, i.e. nc will listen forever for a connection, with or without the −w flag. The default is no timeout.
23 −X proxy_protocol Requests that nc should use the specified protocol when talking to the proxy server. Supported protocols are ‘‘4’’ (SOCKS v.4), ‘‘5’’ (SOCKS v.5) and ‘‘connect’’ (HTTPS proxy). If the protocol is not specified, SOCKS version 5 is used.
24 −x proxy_address[:port] Requests that nc should connect to hostname using a proxy at proxy_address and port. If port is not specified, the well-known port for the proxy protocol is used (1080 for SOCKS, 3128 for HTTPS).
25 −z Specifies that nc should just scan for listening daemons, without sending any data to them. It is an error to use this option in conjunction with the −l option.


  hostname can be a numerical IP address or a symbolic hostname (unless
  the −n option is given). In general, a hostname must be specified,
  unless the −l option is given (in which case the local host is used).
  port[s] can be single integers or ranges. Ranges are in the form nn-mm.
  In general, a destination port must be specified, unless the −U option
  is given (in which case a socket must be specified).

CLIENT/SERVER MODEL

  It is quite simple to build a very basic client/server model using nc.
  On one console, start nc listening on a specific port for a connection.
  For example:
  $ nc -l 1234
  nc is now listening on port 1234 for a connection. On a second console
  (or a second machine), connect to the machine and port being listened
  on:
  $ nc 127.0.0.1 1234
  There should now be a connection between the ports. Anything typed at
  the second console will be concatenated to the first, and vice-versa.
  After the connection has been set up, nc does not really care which
  side is being used as a ‘server’ and which side is being used as a
  ‘client’. The connection may be terminated using an EOF (‘^D’).

DATA TRANSFER

  The example in the previous section can be expanded to build a basic
  data transfer model. Any information input into one end of the
  connection will be output to the other end, and input and output can be
  easily captured in order to emulate file transfer.
  Start by using nc to listen on a specific port, with output captured
  into a file:
  $ nc -l 1234 > filename.out
  Using a second machine, connect to the listening nc process, feeding it
  the file which is to be transferred:
  $ nc host.example.com 1234 < filename.in
  After the file has been transferred, the connection will close
  automatically.

TALKING TO SERVERS

  It is sometimes useful to talk to servers ‘‘by hand’’ rather than
  through a user interface. It can aid in troubleshooting, when it might
  be necessary to verify what data a server is sending in response to
  commands issued by the client. For example, to retrieve the home page
  of a web site:
  $ echo -n "GET / HTTP/1.0\r\n\r\n" | nc host.example.com 80
  Note that this also displays the headers sent by the web server. They
  can be filtered, using a tool such as sed(1), if necessary.
  More complicated examples can be built up when the user knows the
  format of requests required by the server. As another example, an email
  may be submitted to an SMTP server using:
  $ nc [-C] localhost 25 << EOF
  HELO host.example.com
  MAIL FROM:<user@host.example.com>
  RCPT TO:<user2@host.example.com>
  DATA
  Body of email.
  .
  QUIT
  EOF

PORT SCANNING

  It may be useful to know which ports are open and running services on a
  target machine. The −z flag can be used to tell nc to report open
  ports, rather than initiate a connection. For example:
  $ nc -z host.example.com 20-30
  Connection to host.example.com 22 port [tcp/ssh] succeeded!
  Connection to host.example.com 25 port [tcp/smtp] succeeded!
  The port range was specified to limit the search to ports 20 − 30.
  Alternatively, it might be useful to know which server software is
  running, and which versions. This information is often contained within
  the greeting banners. In order to retrieve these, it is necessary to
  first make a connection, and then break the connection when the banner
  has been retrieved. This can be accomplished by specifying a small
  timeout with the −w flag, or perhaps by issuing a "QUIT" command to the
  server:
  $ echo "QUIT" | nc host.example.com 20-30
  SSH-1.99-OpenSSH_3.6.1p2
  Protocol mismatch.
  220 host.example.com IMS SMTP Receiver Version 0.84 Ready

(more) EXAMPLES

  Open a TCP connection to port 42 of host.example.com, using port 31337
  as the source port, with a timeout of 5 seconds:
  $ nc -p 31337 -w 5 host.example.com 42
  Open a UDP connection to port 53 of host.example.com:
  $ nc -u host.example.com 53
  Open a TCP connection to port 42 of host.example.com using 10.1.2.3 as
  the IP for the local end of the connection:
  $ nc -s 10.1.2.3 host.example.com 42
  Create and listen on a Unix Domain Socket:
  $ nc -lU /var/tmp/dsocket
  Connect to port 42 of host.example.com via an HTTP proxy at 10.2.3.4,
  port 8080. This example could also be used by ssh(1); see the
  ProxyCommand directive in ssh_config(5) for more information.
  $ nc -x10.2.3.4:8080 -Xconnect host.example.com 42
  The same example again, this time enabling proxy authentication with
  username ‘‘ruser’’ if the proxy requires it:
  $ nc -x10.2.3.4:8080 -Xconnect -Pruser host.example.com 42

SEE ALSO

  cat(1), ssh(1)

AUTHORS

  Original implementation by *Hobbit* 〈 hobbit@avian.org〉 .
  Rewritten with IPv6 support by Eric Jackson <ericj@monkey.org>.

CAVEATS

  UDP port scans will always succeed (i.e. report the port as open),
  rendering the −uz combination of flags relatively useless.
  BSD April 22, 2017 BSD

setserial

Die Angaben beziehen sich auf setserial version 2.17, 27-Jan-2000.

NAME

  setserial − get/set Linux serial port information

SYNOPSIS

  setserial [ −abqvVWz ] device [ parameter1 [ arg ] ] ...
  setserial -g [ −abGv ] device1 ...

Man beachte hier die eckige Klammerung mit Leerzeichen und die Reihenfolge aller Übergabeparameter, die nicht mit der Angabe der Ausgabe bei z. B. -v übereinstimmt!

  1. setserial -v

setserial version 2.17, 27-Jan-2000

usage: setserial serial-device -abqvVWz [cmd1 [arg]] ...

        setserial -g [-abGv] device1 ...

DESCRIPTION

  setserial is a program designed to set and/or report the configuration
  information associated with a serial port. This information includes
  what I/O port and IRQ a particular serial port is using, and whether or
  not the break key should be interpreted as the Secure Attention Key,
  and so on.
  During the normal bootup process, only COM ports 1-4 are initialized,
  using the default I/O ports and IRQ values, as listed below. In order
  to initialize any additional serial ports, or to change the COM 1-4
  ports to a nonstadard configuration, the setserial program should be
  used. Typically it is called from an rc.serial script, which is usually
  run out of /etc/rc.local.
  The device argument or arguments specifies the serial device which
  should be configured or interrogated. It will usually have the
  following form: /dev/cua[0-3].
  If no parameters are specified, setserial will print out the port type
  (i.e., 8250, 16450, 16550, 16550A, etc.), the hardware I/O port, the
  hardware IRQ line, its "baud base," and some of its operational flags.
  If the −g option is given, the arguments to setserial are interpreted
  as a list of devices for which the characteristics of those devices
  should be printed.
  Without the −g option, the first argument to setserial is interpreted
  as the device to be modified or characteristics to be printed, and any
  additional arguments are interpreted as parameters which should be
  assigned to that serial device.
  For the most part, superuser privilege is required to set the
  configuration parameters of a serial port. A few serial port parameters
  can be set by normal users, however, and these will be noted as
  exceptions in this manual page.

OPTIONS

  Setserial accepts the following options:


Nr. Option Originaltext Übersetzung/Erläuterung
1 -a When reporting the configuration of a serial device, print all available information. Beispiel
2 -b When reporting the configuration of a serial device, print a summary of the device’s configuration, which might be suitable for printing during the bootup process, during the /etc/rc script. Beispiel
3 -G Print out the configuration information of the serial port in a form which can be fed back to setserial as command-line arguments. Beispiel
4 -q Be quiet. Setserial will print fewer lines of output. Beispiel
5 -v Be verbose. Setserial will print additional status output. Beispiel
6 -V Display version and exit. Beispiel
7 -W Do wild interrupt initialization and exit. This option is no longer relevant in Linux kernels after version 2.1. Beispiel
8 -z Zero out the serial flags before starting to set flags. This is related to the automatic saving of serial flags using the −G flag. Beispiel

PARAMETERS

  The following parameters can be assigned to a serial port.
  All argument values are assumed to be in decimal unless preceeded by
  "0x".
  port port_number
  The port option sets the I/O port, as described above.
  irq irq_number
  The irq option sets the hardware IRQ, as described above.
  uart uart_type
  This option is used to set the UART type. The permitted types are none,
  8250, 16450, 16550, 16550A, 16650, 16650V2, 16654, 16750, 16850, 16950,
  and 16954. Using UART type none will disable the port.
  Some internal modems are billed as having a "16550A UART with a 1k
  buffer". This is a lie. They do not have really have a 16550A
  compatible UART; instead what they have is a 16450 compatible UART with
  a 1k receive buffer to prevent receiver overruns. This is important,
  because they do not have a transmit FIFO. Hence, they are not
  compatible with a 16550A UART, and the autoconfiguration process will
  correctly identify them as 16450’s. If you attempt to override this
  using the uart parameter, you will see dropped characters during file
  transmissions. These UART’s usually have other problems: the skip_test
  parameter also often must be specified.
  autoconfig
  When this parameter is given, setserial will ask the kernel to attempt
  to automatically configure the serial port. The I/O port must be
  correctly set; the kernel will attempt to determine the UART type, and
  if the auto_irq parameter is set, Linux will attempt to automatically
  determine the IRQ. The autoconfig parameter should be given after the
  port,auto_irq, and skip_test parameters have been specified.
  auto_irq
  During autoconfiguration, try to determine the IRQ. This feature is not
  guaranteed to always produce the correct result; some hardware
  configurations will fool the Linux kernel. It is generally safer not to
  use the auto_irq feature, but rather to specify the IRQ to be used
  explicitly, using the irq parameter.
  ^auto_irq
  During autoconfiguration, do not try to determine the IRQ.
  skip_test
  During autoconfiguration, skip the UART test. Some internal modems do
  not have National Semiconductor compatible UART’s, but have cheap
  imitations instead. Some of these cheasy imitations UART’s do not fully
  support the loopback detection mode, which is used by the kernel to
  make sure there really is a UART at a particular address before
  attempting to configure it. So for certain internal modems you will
  need to specify this parameter so Linux can initialize the UART
  correctly.
  ^skip_test
  During autoconfiguration, do not skip the UART test.
  baud_base baud_base
  This option sets the base baud rate, which is the clock frequency
  divided by 16. Normally this value is 115200, which is also the fastest
  baud rate which the UART can support.
  spd_hi
  Use 57.6kb when the application requests 38.4kb. This parameter may be
  specified by a non-privileged user.
  spd_vhi
  Use 115kb when the application requests 38.4kb. This parameter may be
  specified by a non-privileged user.
  spd_shi
  Use 230kb when the application requests 38.4kb. This parameter may be
  specified by a non-privileged user.
  spd_warp
  Use 460kb when the application requests 38.4kb. This parameter may be
  specified by a non-privileged user.
  spd_cust
  Use the custom divisor to set the speed when the application requests
  38.4kb. In this case, the baud rate is the baud_base divided by the
  divisor. This parameter may be specified by a non-privileged user.
  spd_normal
  Use 38.4kb when the application requests 38.4kb. This parameter may be
  specified by a non-privileged user.
  divisor divisor
  This option sets the custom divison. This divisor will be used then the
  spd_cust option is selected and the serial port is set to 38.4kb by the
  application. This parameter may be specified by a non-privileged user.
  sak
  Set the break key at the Secure Attention Key.
  ^sak
  disable the Secure Attention Key.
  fourport
  Configure the port as an AST Fourport card.
  ^fourport
  Disable AST Fourport configuration.
  close_delay delay
  Specify the amount of time, in hundredths of a second, that DTR should
  remain low on a serial line after the callout device is closed, before
  the blocked dialin device raises DTR again. The default value of this
  option is 50, or a half-second delay.
  closing_wait delay
  Specify the amount of time, in hundredths of a second, that the kernel
  should wait for data to be transmitted from the serial port while
  closing the port. If "none" is specified, no delay will occur. If
  "infinite" is specified the kernel will wait indefinitely for the
  buffered data to be transmitted. The default setting is 3000 or 30
  seconds of delay. This default is generally appropriate for most
  devices. If too long a delay is selected, then the serial port may hang
  for a long time if when a serial port which is not connected, and has
  data pending, is closed. If too short a delay is selected, then there
  is a risk that some of the transmitted data is output at all. If the
  device is extremely slow, like a plotter, the closing_wait may need to
  be larger.
  session_lockout
  Lock out callout port (/dev/cuaXX) accesses across different sessions.
  That is, once a process has opened a port, do not allow a process with
  a different session ID to open that port until the first process has
  closed it.
  ^session_lockout
  Do not lock out callout port accesses across different sessions.
  pgrp_lockout
  Lock out callout port (/dev/cuaXX) accesses across different process
  groups. That is, once a process has opened a port, do not allow a
  process in a different process group to open that port until the first
  process has closed it.
  ^pgrp_lockout
  Do not lock out callout port accesses across different process groups.
  hup_notify
  Notify a process blocked on opening a dial in line when a process has
  finished using a callout line (either by closing it or by the serial
  line being hung up) by returning EAGAIN to the open.
  The application of this parameter is for getty’s which are blocked on a
  serial port’s dial in line. This allows the getty to reset the modem
  (which may have had its configuration modified by the application using
  the callout device) before blocking on the open again.
  ^hup_notify
  Do not notify a process blocked on opening a dial in line when the
  callout device is hung up.
  split_termios
  Treat the termios settings used by the callout device and the termios
  settings used by the dialin devices as separate.
  ^split_termios
  Use the same termios structure to store both the dialin and callout
  ports. This is the default option.
  callout_nohup
  If this particular serial port is opened as a callout device, do not
  hangup the tty when carrier detect is dropped.
  ^callout_nohup
  Do not skip hanging up the tty when a serial port is opened as a
  callout device. Of course, the HUPCL termios flag must be enabled if
  the hangup is to occur.
  low_latency
  Minimize the receive latency of the serial device at the cost of
  greater CPU utilization. (Normally there is an average of 5-10ms
  latency before characters are handed off to the line discpline to
  minimize overhead.) This is off by default, but certain real-time
  applications may find this useful.
  ^low_latency
  Optimize for efficient CPU processing of serial characters at the cost
  of paying an average of 5-10ms of latency before the characters are
  processed. This is the default.

CONSIDERATIONS OF CONFIGURING SERIAL PORTS

  It is important to note that setserial merely tells the Linux kernel
  where it should expect to find the I/O port and IRQ lines of a
  particular serial port. It does *not* configure the hardware, the
  actual serial board, to use a particular I/O port. In order to do that,
  you will need to physically program the serial board, usually by
  setting some jumpers or by switching some DIP switches.
  This section will provide some pointers in helping you decide how you
  would like to configure your serial ports.
  The "standard MS-DOS" port associations are given below:
  /dev/ttys0 (COM1), port 0x3f8, irq 4
  /dev/ttys1 (COM2), port 0x2f8, irq 3
  /dev/ttys2 (COM3), port 0x3e8, irq 4
  /dev/ttys3 (COM4), port 0x2e8, irq 3
  Due to the limitations in the design of the AT/ISA bus architecture,
  normally an IRQ line may not be shared between two or more serial
  ports. If you attempt to do this, one or both serial ports will become
  unreliable if you try to use both simultaneously. This limitation can
  be overcome by special multi-port serial port boards, which are
  designed to share multiple serial ports over a single IRQ line.
  Multi-port serial cards supported by Linux include the AST FourPort,
  the Accent Async board, the Usenet Serial II board, the Bocaboard
  BB-1004, BB-1008, and BB-2016 boards, and the HUB-6 serial board.
  The selection of an alternative IRQ line is difficult, since most of
  them are already used. The following table lists the "standard MS-DOS"
  assignments of available IRQ lines:
  IRQ 3: COM2
  IRQ 4: COM1
  IRQ 5: LPT2
  IRQ 7: LPT1
  Most people find that IRQ 5 is a good choice, assuming that there is
  only one parallel port active in the computer. Another good choice is
  IRQ 2 (aka IRQ 9); although this IRQ is sometimes used by network
  cards, and very rarely VGA cards will be configured to use IRQ 2 as a
  vertical retrace interrupt. If your VGA card is configured this way;
  try to disable it so you can reclaim that IRQ line for some other card.
  It’s not necessary for Linux and most other Operating systems.
  The only other available IRQ lines are 3, 4, and 7, and these are
  probably used by the other serial and parallel ports. (If your serial
  card has a 16bit card edge connector, and supports higher interrupt
  numbers, then IRQ 10, 11, 12, and 15 are also available.)
  On AT class machines, IRQ 2 is seen as IRQ 9, and Linux will interpret
  it in this manner.
  IRQ’s other than 2 (9), 3, 4, 5, 7, 10, 11, 12, and 15, should not be
  used, since they are assigned to other hardware and cannot, in general,
  be changed. Here are the "standard" assignments:
  IRQ 0 Timer channel 0
  IRQ 1 Keyboard
  IRQ 2 Cascade for controller 2
  IRQ 3 Serial port 2
  IRQ 4 Serial port 1
  IRQ 5 Parallel port 2 (Reserved in PS/2)
  IRQ 6 Floppy diskette
  IRQ 7 Parallel port 1
  IRQ 8 Real-time clock
  IRQ 9 Redirected to IRQ2
  IRQ 10 Reserved
  IRQ 11 Reserved
  IRQ 12 Reserved (Auxillary device in PS/2)
  IRQ 13 Math coprocessor
  IRQ 14 Hard disk controller
  IRQ 15 Reserved

MULTIPORT CONFIGURATION

  Certain multiport serial boards which share multiple ports on a single
  IRQ use one or more ports to indicate whether or not there are any
  pending ports which need to be serviced. If your multiport board
  supports these ports, you should make use of them to avoid potential
  lockups if the interrupt gets lost.
  In order to set these ports specify set_multiport as a parameter, and
  follow it with the multiport parameters. The multiport parameters take
  the form of specifying the port that should be checked, a mask which
  indicate which bits in the register are significant, and finally, a
  match parameter which specifies what the significant bits in that
  register must match when there is no more pending work to be done.
  Up to four such port/mask/match combinations may be specified. The
  first such combinations should be specified by setting the parameters
  port1, mask1, and match1. The second such combination should be
  specified with port2, mask2, and match2, and so on. In order to disable
  this multiport checking, set port1 to be zero.
  In order to view the current multiport settings, specify the parameter
  get_multiport on the command line.
  Here are some multiport settings for some common serial boards:
  AST FourPort port1 0x1BF mask1 0xf match1 0xf
  Boca BB-1004/8 port1 0x107 mask1 0xff match1 0
  Boca BB-2016 port1 0x107 mask1 0xff match1 0
  port2 0x147 mask2 0xff match2 0

Hayes ESP Configuration

  Setserial may also be used to configure ports on a Hayes ESP serial
  board.
  The following parameters when configuring ESP ports:
  rx_trigger
  This is the trigger level (in bytes) of the receive FIFO. Larger values
  may result in fewer interrupts and hence better performance; however, a
  value too high could result in data loss. Valid values are 1 through
  1023.
  tx_trigger
  This is the trigger level (in bytes) of the transmit FIFO. Larger
  values may result in fewer interrupts and hence better performance;
  however, a value too high could result in degraded transmit
  performance. Valid values are 1 through 1023.
  flow_off
  This is the level (in bytes) at which the ESP port will "flow off" the
  remote transmitter (i.e. tell him to stop stop sending more bytes).
  Valid values are 1 through 1023. This value should be greater than the
  receive trigger level and the flow on level.
  flow_on
  This is the level (in bytes) at which the ESP port will "flow on" the
  remote transmitter (i.e. tell him to resume sending bytes) after having
  flowed it off. Valid values are 1 through 1023. This value should be
  less than the flow off level, but greater than the receive trigger
  level.
  rx_timeout
  This is the amount of time that the ESP port will wait after receiving
  the final character before signaling an interrupt. Valid values are 0
  through 255. A value too high will increase latency, and a value too
  low will cause unnecessary interrupts.

CAUTION

  CAUTION: Configuring a serial port to use an incorrect I/O port can
  lock up your machine.

FILES

  /etc/rc.local /etc/rc.serial

SEE ALSO

  tty(4), ttys(4), kernel/chr_drv/serial.c

AUTHOR

  The original version of setserial was written by Rick Sladkey
  (jrs@world.std.com), and was modified by Michael K. Johnson
  (johnsonm@stolaf.edu).
  This version has since been rewritten from scratch by Theodore Ts’o
  (tytso@mit.edu) on 1/1/93. Any bugs or problems are solely his
  responsibility.

statserial

Die Angaben beziehen sich auf die Version 1.1-743.2.

NAME

  statserial − display serial port modem status lines

SYNOPSIS

  statserial [-n | -d | -x] <device-name>

DESCRIPTION

  Statserial displays a table of the signals on a standard 9-pin or
  25-pin serial port, and indicates the status of the handshaking lines.
  It can be useful for debugging problems with serial ports or modems.
  The optional device-name parameter is the full name of the device file
  for the serial port in question. If not specified, the default is taken
  from the environment variable MODEM if set, otherwise /dev/cua1.

COMMAND−LINE OPTIONS

  Each of the command line options is mutually exclusive.
  -n
  Normally statserial will loop continuously, updating the status at one
  second intervals; you can exit using Control-C. The -n option disables
  looping.
  -d
  With this option the status of the modem is printed as a decimal
  number. The bits are encoded as follows (XXX indicates unused bits):
  +---+---+---+---+---+---+---+---+---+
  | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  +---+---+---+---+---+---+---+---+---+
  |DSR|RI |DCD|CTS|XXX|XXX|RTS|DTR|XXX|
  +---+---+---+---+---+---+---+---+---+
  -x
  This option is the same as -d, except that the output is in
  hexadecimal.

BUGS/LIMITATIONS

  Statserial only works with devices that support the TIOCMGET ioctl.
  You need permission to read the device file.
  The device file may be locked if other applications are using it.

AUTHOR

  Statserial was written by Jeff Tranter (Jeff_Tranter@Mitel.COM), later
  updated by Frank Baumgart (godot@uni-paderborn.de) and is released
  under the conditions of the GNU General Public License. See the file
  COPYING and notes in the source code for details.

SEE ALSO

  setserial(8) stty(1)
  /usr/src/linux/drivers/char/serial.c /usr/include/linux/termios.h