COM to TCP bridge with support for WebSocket


Bridges a serial port to a TCP socket, or UDP stream. TLS, and WebSocket are also supported. In server mode the protocol requested by client is used, RAW can be used as a fallback if no protocol is detected. In client mode, the use of protocol is configured from the command line. Secure connections require a certificate file in the current directory with the name gvalkov.com.pem.

Command line options

gncom <-l --listen> <-p source port>
gncom <host IP> <port>
[-s source IP]
[-p source port]
[-c 31 connections]
[-P --print packets] [-O --once   print only the first packet]
[-v --verbose]       [-q --quiet  connect silently]
[-L 1472|-L 65112  packet length]
[-u -udp]
[-w --websocket  send as text if detected, fallback to binary]
[-a --text     WebSocet]
[-b --binary   WebSocket]
[-e --echo     bytes from COM port (default)]
[-E --no-echo  bytes from COM port]
[-t --tls]
[-F --forward data between clients (default)]
[-N --no-forward  data between clients]
[-H --honeypot]
[-T --test]  print data from COM port without opening a network socket
[-f ttyS0|-f /dev/ttyS0|-f /dev/ttyUSB0]  # UNIX
[-f COM1|-f \\.\COM1|-f \\.\COM2]         # Windows
[-i pipe|\\.\pipe\name]  -i open existing pipe, use -I to create
[-r 115200  baud rate]
[-b 8] 5-8: byte size --5bits --6bits --7bits --8-bits
[-Y 0] 0: --no-parity,    1: --odd-parity, 2: --even-parity
       3: --mark-parity,  4: --space-parity
[-S 0] 0: --one-stop bit, 1: --one5-stop 1.5 stop bits, 2: --two-stop

Sample use

gncom -lp 81
gncom -lp 81 -r 115200 -f /dev/ttyUSB0    # UNIX
gncom -lp 81 -r 115200 -f \\.\COM2        # Windows
gncom -lp 81 -s
gncom 81 -s -p 81

Honeypot warning

Normally the program accepts connections or connects to some server, then reads the incomming packets, which frees system resources and enables normal communication over the network. The --honeypot (-H) switch disables the receiving task. This may jam system resources and disrupt network communications. Some Wi-Fi cards disconnect, if a client in this mode starts receiving data.

Supported Platforms

☂︎ Apple iOS, macOS
☂︎ FreeBSD
☂︎ Linux, OpenWRT
☂︎ Windows

Prerequisites and build instructions

© 2017-2023 Georgi Valkov