socat is a very powerful utility program for estabilishing bi-directional data streams between two data sinks/sources. It can be used for creating two virtual COM ports that relay information to each other.


On Debian-based operating systems (such as Ubuntu), you can type:

Connecting Two COM Ports Together

You can use socat to connect two COM ports together. This means that any information sent to one will appear as input on the other, and vise-versa.

To set up the two-way communication, you type:

A little explanation: The -d -d instructs socat to print fatal, error and warning message. pty instructs socat to connect to a pseudo-terminal (e.g. /dev/pts/0, /dev/pts/1, …). raw instructs socat to do almost not processing on input/output, and just pass it untouched. echo=0 tells socat not to echo any input characters back to the same terminal (which is normally the desired behaviour when connecting two COM ports).

Once you type this and press enter, socat will report back with the COM ports it decided to use. The program will not return (the terminal will hang) until you wish to cancel the link (press Ctrl-C).

Posted: January 8th, 2014 at 8:18 pm
Last Updated on: January 9th, 2014 at 9:06 am