RFC 2217 With hub4com: Share a Serial Port Over the Network

A plain serial-to-TCP bridge moves bytes, but a serial port is more than bytes: it has a baud rate, data bits, parity, and modem signals like DTR and CTS that real applications expect to control. RFC 2217, the “Telnet Com Port Control Option”, is the protocol that carries those settings and signals across the network, so a port on another computer behaves like a port on yours. In the com0com project, RFC 2217 belongs to hub4com — its changelog records “Implemented RFC 2217 ‘Telnet Com Port Control Option’ protocol” in version 2.0.0.0 — and it is exposed through the com2tcp-rfc2217.bat wrapper. This page gives you the official server and client recipes, from the hub4com ReadMe, exactly as the project documents them.

Server: share this PC’s serial port

The scenario from the ReadMe: “You have a server computer with physical COM1 port and you’d like to share it through the network by the RFC 2217 protocol.” One command starts the server:

com2tcp-rfc2217 COM1 7000

In the ReadMe’s words, “it will listen TCP/IP port 7000 for incoming connections and redirect them to COM1 port.” That is the whole server: the wrapper configures hub4com with the RFC 2217 server-side filters, opens COM1, and waits. Any RFC 2217 client — the matching wrapper below, a commercial redirector, a device server acting as a client — can now connect to this PC on TCP port 7000 and use COM1 as its own.

Firewall note: the server PC must accept inbound TCP connections on the port you chose (7000 in the example). Windows Firewall will typically prompt the first time hub4com listens, or you can add an inbound rule for TCP 7000 scoped to your local network. If the server starts without error but no client can reach it, the firewall — not the serial side — is the first suspect.

Client: make the remote port a local virtual port

On the client computer, the remote port becomes usable once it has a local face — a com0com virtual port. The ReadMe’s client example creates a pair first, giving the application-facing end the name COM5 and, notably, enabling baud rate emulation on it:

command> install 0 PortName=COM5,EmuBR=yes -

Then the wrapper connects the pair’s inner end to the server:

com2tcp-rfc2217 \\.\CNCB0 your.comport.server 7000

As the ReadMe puts it, this “will redirect virtual serial port COM5 on the second computer to the physical serial port on the first computer.” Applications on the client open COM5 exactly as if the device were plugged in locally; the RFC 2217 negotiation carries baud rate, parity and signal changes across the wire to the real port. (The EmuBR=yes in the pair creation is the driver’s baud rate emulation switch — the EmuBR/EmuOverrun guide explains what it does and why the project pairs it with network use.)

Wrapper options worth knowing

The com2tcp-rfc2217.bat usage text (run it with --help) documents more than the two recipes. The ones that matter in practice:

  • --share-com-port — in the usage text’s words, “open the com port on connecting and close it on disconnecting. By default the com port is open permanently.” On the server side this lets the port be used locally between network sessions instead of being held by the wrapper forever.
  • --reconnect <t> (client mode) — force reconnection to the remote host after a disconnect, with the interval in milliseconds, for links that must heal themselves.
  • --connect <state> and --delay-disconnect <t> — make the network connection follow a modem signal (CTS, DSR, DCD, ring or break), and smooth over brief signal drops before actually disconnecting.
  • --keep-active <s> — send a NOP every so many seconds so idle connections are not torn down by intermediaries.
  • --interface <if> — bind listening or connecting to a specific network interface, on multi-homed PCs.

How the wrapper knows client from server

One detail confuses everyone the first time: the same batch file runs both ends. The disambiguation is in the arguments, as the wrapper’s usage text lays out. Give it a COM port and two further arguments — a host address and a host port — and you are in TCP client mode: it connects out to a listening server. Give it a COM port and one further argument — a listen port — and you are in TCP server mode: it waits for someone else to connect. The usage text also documents an explicit override, --rfc2217-mode {c|s}, noting that the default is client for TCP client mode and server for TCP server mode — in practice, the argument shape decides, and the option exists for the unusual setups where you need to force the serial-side role independently. If your wrapper “does nothing”, count your arguments first: a missing host address quietly turns a client into a server waiting for a connection that will never come.

One less thing to debug than you might fear: the wrapper starts hub4com with CTS handshaking on output already disabled for the COM side (its generated command includes --octs=off) — the silent-real-port trap from the hub’s FAQ is pre-disarmed here, unlike in raw hub4com setups.

An honest word about security

RFC 2217 is a telnet-family protocol from the era of trusted networks: in the form these recipes use it, the traffic — data and serial settings alike — crosses the network unencrypted, and the server side has no meaningful authentication. Treat TCP 7000 like a serial cable anyone on the path can unplug or splice. Run it on a LAN you trust, or inside a VPN tunnel; do not expose the listening port to the internet. Note also that the plain server recipe listens without restricting which interface or which callers are accepted — the wrapper’s --interface option can bind it to a specific adapter, and your firewall rules should assume that anything on the network that can reach the port can use the device behind it until you have deliberately narrowed that down. For the same reason, think before sharing a port attached to anything safety- or security-relevant: whoever can reach the port can drive the device.

Alternatives, honestly ranked

  • HW VSP3 — a free single-port virtual serial port redirector from HW group, if all you need is one port over Ethernet and you prefer a dedicated tool to a wrapper script. The product is in run-out, but the free single-port version still covers the simple redirector case.
  • Plain com2tcp — if the far end does not speak RFC 2217 and you only need raw bytes bridged, the simpler redirector in our com2tcp guide has fewer moving parts.
  • A dedicated serial device server — when the “server computer” should not have to be a PC left running at all, a small hardware box puts the serial port on the network permanently; see serial device servers on Amazon (sponsored). This is the one commercial step-up that genuinely changes the setup rather than just re-skinning it.

Between the two recipes above you have the complete RFC 2217 pattern the project supports: publish with com2tcp-rfc2217 <port> <tcp port>, consume with a virtual pair and the matching client command. For the sibling jobs — sharing one port between several local applications, or bridging without RFC 2217 — see GPS sharing with hub4com and the port splitting guide.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *