取代netcat的瑞士军刀socat

desc

包含的工具

工作原理 - life cycle of a socat instance (4 phases)

  1. init phase(初始化阶段), the command line options are parsed and logging is initialized. (解析命令行以及初始化日志系统.)
  2. open phase(打开连接阶段), 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. (先打开第一个连接, 再打开第二个连接. 这个单步执行的. 如果第一个连接失败, 则会直接退出.)
  3. 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. (谁有数据就转发到另外一个连接上, read/write互换.)
  4. closing phase(关闭阶段), one of the streams effectively reaches EOF. 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

Address specifications

Address Types

Address Options

Data Values

Refs