Skip to content
ENGINEERING TIPS // EMBEDDED LINUX & SERIAL DEBUGGING

Network-to-Serial Bridge Using Netcat & Socat

During embedded Linux bring-up and remote hardware-in-the-loop testing, engineers often need to expose a local UART serial port (/dev/ttyS0 or /dev/ttyUSB0) over a TCP socket. This technical note shows how to configure raw baud rates with stty and bridge serial ports over TCP using netcat (nc) or socat.

Technical Notes & Reference Details

  • Configure serial port raw mode and baud rate: stty -F /dev/ttyS0 raw 9600
  • Expose serial port on TCP port 7000 with Netcat: nc -l -p 7000 < /dev/ttyS0 > /dev/ttyS0
  • Expose serial port on TCP port 7000 with Socat: socat tcp-l:7000,reuseaddr,fork file:/dev/ttyS0,nonblock,raw,echo=0,waitlock=/var/run/tty,b9600
  • Connect from remote workstation: nc <target-ip-address> 7000

Datasheets, Source Code & Reference Links