About
socat joins two data channels of almost any kind and copies bytes between them. A port, socket, file or serial line can all be connected. It is the tool for quick relays and small bridges.
Install it
pkg install socat
Run this inside Termux. If the package is already present, pkg will say so and
do nothing.
Commands worth knowing
5 of the invocations you will actually reach for. Tap the copy button to put one on your clipboard.
socat TCP-LISTEN:8080,fork TCP:127.0.0.1:80 Forward every connection on port 8080 to a local web server. A quick way to relay a service. socat TCP:example.com:80 Open a plain stream to a remote port and pipe data through it. The building block for many relays. socat UNIX-LISTEN:/tmp/app.sock,fork UNIX-CONNECT:/tmp/real.sock Bridge two Unix sockets to move a program fixed to one path. socat UDP-RECVFROM:9999,fork - Receive UDP datagrams and print them. A simple way to inspect traffic a stream tool would miss. socat OPEN:notes.txt CREATE:/tmp/out.txt Copy a file through the same channel machinery. Occasionally useful for testing a data path. Developed by
Gerhard Rieger .