Redirect serial com to tcp port

It's pretty easy. Under Linux there are serial devices, redirection and netcat for that. On the server you can run a netcat process listening on a given tcp port with stdin and stdout redirected to/from the serial device like that:

nc -l 9801 > /dev/ttyS0 < /dev/ttyS0

Where 9801 in this example is the tcp port to listen on. You can setup the serial port with setserial(8).

These device files also exist on cygwin (Windows).


I think socat has the functionality you are looking for as well.

$ socat TCP-LISTEN:4161,fork,reuseaddr FILE:/dev/ttyUSB0,b57600,raw