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 properties and for debugging socat, but might be useful for other purposes too.

The life cycle of a socat instance typically consists of four phases.

In the 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 streamscq read and write file descriptors via CWselect() , 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 socatcontinues to transfer data in the other direction, but then closes all remaining channels and terminates.



socat [options] <bi-address> <bi-address>


      -V             print version and feature information to stdout, and exit
      -h|-?          print a help text describing command line options and addresses
      -hh            like -h, plus a list of all common address option names
      -hhh           like -hh, plus a list of all available address option names
      -d             increase verbosity (use up to 4 times; 2 are recommended)
      -D             analyze file descriptors before loop
      -ly[facility]  log to syslog, using facility (default is daemon)
      -lf<logfile>   log to file
      -ls            log to stderr (default if no other log)
      -lm[facility]  mixed log mode (stderr during initialization, then syslog)
      -lp<progname>  set the program name used for logging
      -lu            use microseconds for logging timestamps
      -lh            add hostname to log messages
      -v             verbose data traffic, text
      -x             verbose data traffic, hexadecimal
      -b<size_t>     set data buffer size (8192)
      -s             sloppy (continue on error)
      -t<timeout>    wait seconds before closing second channel
      -T<timeout>    total inactivity timeout in seconds
      -u             unidirectional mode (left to right)
      -U             unidirectional mode (right to left)
      -g             do not check option groups
      -L <lockfile>  try to obtain lock, or fail
      -W <lockfile>  try to obtain lock, or wait
      -4             prefer IPv4 if version is not explicitly specified
      -6             prefer IPv6 if version is not explicitly specified


cyborg@cyborg:~$ socat TCP-LISTEN:5555 SOCKS4A:localhost:,socksport=9050
2015/09/14 18:35:25 socat[5604] E socks: connect request

Leave a reply


We're are building as a community and a team. Be a part of it.


©2018 Ztrela Knowledge Solutions Pvt. Ltd

Log in with your credentials

Forgot your details?