hub4com Guide: The com0com Hub for Sharing, Splitting and Bridging Ports

A com0com pair connects exactly two applications. Real serial work is rarely that tidy: one GPS receiver and three programs that all want its data, a device on another PC that you wish were plugged into yours, a stream you need to watch while it flows. That is the gap hub4com fills. It is a free Windows application from the same SourceForge project and the same author as com0com, and this guide explains how it works using the project’s own documentation — the hub4com ReadMe that ships in the package.

The ReadMe introduces it in one sentence: hub4com “allows to receive data and signals from one port, modify and send it to a number of ports and vice versa.” Everything in this guide is an unpacking of that sentence. The current (and final) release is version 2.1.0.0 from 18 June 2012 — old, unmaintained, and still the reference tool for this job because the job itself has not changed. You can get the package from the hub4com hub page; the driver side of the story lives on the download page.

What hub4com is — and what it is not

hub4com is a user-mode console application, hub4com.exe. It is not a driver: it installs nothing into the kernel and creates no ports of its own. The virtual ports it works with come from the com0com driver, which is why the two tools are always used together — com0com manufactures the ports, hub4com moves data between them and the real world. If the driver itself is not installed yet, start with the Windows 11 installation guide and come back here once you can create a pair.

The ReadMe names the two headline uses directly. In conjunction with the com0com driver, hub4com lets you “handle data and signals from a single real serial device by a number of different applications” — its example is several applications sharing data from one GPS device — and “use real serial ports of remote computer like if they exist on the local computer.” Splitting, joining, redirecting and multiplexing are all variations on those two themes.

The core concepts

1. Ports: real, virtual and network, side by side

When you start hub4com you list the ports it should open on its command line. A port in that list can be a real hardware port such as COM1, one end of a com0com virtual pair such as CNCB0 (written \\.\CNCB0 on the command line), or — with the TCP driver option used in several ReadMe examples — a network endpoint. hub4com does not care which kind each entry is. That indifference is the whole design: to the hub, a GPS receiver, a virtual port and a TCP connection are all just ports that produce and consume data and modem signals.

2. Routing: what comes in one port goes out the others

The ReadMe’s own testing procedure is the clearest demonstration of routing. Create three virtual pairs (CNCA0/CNCB0, CNCA1/CNCB1, CNCA2/CNCB2), start the hub on the three B ends, and attach a terminal to each A end:

hub4com --route=All:All \\.\CNCB0 \\.\CNCB1 \\.\CNCB2

“The data typed to any HyperTerminal window should be printed on the others HyperTerminal windows,” the ReadMe promises — and it is. The --route=All:All option in that command tells the hub to route every port to every port. Other examples route more selectively: in the GPS hub example below, the hub is started with no route option at all, and the ReadMe describes the resulting flow explicitly — data from the real port is sent to both virtual ports, and data from the first virtual port is sent back to the real port. Routing is how you decide who hears whom.

3. Filters: modify the stream as it passes

The middle word of the ReadMe’s definition — “modify” — is the filters system. A filter is a named processing step you create and then attach to a port. The ReadMe’s chat-server example builds one with --create-filter=telnet and attaches it with --add-filters=All:telnet so that plain telnet clients can join the hub; its other examples use a pinmap filter to map modem pins (for instance, raising DTR while a connection is up) and a trace filter to watch traffic. You do not need filters for basic sharing, but knowing they exist explains most of the longer command lines you will find in the official examples: the ports are the nouns, the filters are the adjectives.

4. Wrappers: one-purpose shortcuts around the hub

Three batch files in the package are, in the ReadMe’s FAQ wording, “wrappers to the hub4com.exe”: com2tcp.bat (COM port to TCP redirector), com2tcp-rfc2217.bat (the same, speaking the RFC 2217 protocol) and multiplexer.bat (several ports carried over a single link). Each translates a short, friendly command line into a long hub4com invocation with the right filters preconfigured. Use the wrappers for the jobs they name — our com2tcp guide and RFC 2217 guide cover both — and drop to raw hub4com when you need routing or filters of your own.

Your first hub: the ReadMe’s four-step test

Before building anything real, run the project’s own smoke test. It takes a few minutes and proves the driver, the hub and your understanding of routing in one go.

  1. Create three pairs. In the Setup Command Prompt, create pairs so that CNCA0/CNCB0, CNCA1/CNCB1 and CNCA2/CNCB2 exist (the first-pair guide and the setupc command reference cover the syntax).
  2. Start the hub on the three B ends with the routing command shown above: hub4com --route=All:All \\.\CNCB0 \\.\CNCB1 \\.\CNCB2. Leave the console window open — the hub runs in it, and closing it stops the hub.
  3. Open a terminal on each A end — CNCA0, CNCA1 and CNCA2 — in any terminal program (the ReadMe used HyperTerminal; any modern equivalent works).
  4. Type in any window. Your characters should appear in the other two windows. That is a working three-way hub: every port routed to every port.

If nothing appears, the most common cause with real ports is flow control, and the ReadMe’s FAQ answers it directly: “By default hub4com use CTS handshaking on output so if CTS state is OFF then no any data can be sent to the port. To disable CTS handshaking add --octs=off option before real com port.” Keep that one in your pocket; it is the single most useful hub4com troubleshooting fact there is.

A practical hub: sharing one device

The test above becomes useful the moment one of the ports is real. The ReadMe’s GPS hub starts the hub like this:

hub4com \\.\COM1 \\.\CNCB0 \\.\CNCB1

Here COM1 is a physical GPS receiver, and CNCB0/CNCB1 are the inner ends of two virtual pairs whose outer ends (renamed COM5 and COM6) are what the applications open. The receiver’s data reaches both applications; one application’s data can flow back to the receiver. That three-line pattern — one real port, hub, two or more virtual ends — is the template for almost every real hub4com setup, including port splitting and GPS sharing. The full walkthrough, including creating the pairs with the ReadMe’s exact commands, is our GPS sharing recipe; the general case is covered in Split One Serial Port Between Several Applications.

Reading the official examples folder

The package’s examples folder and the ReadMe’s “Examples of usage” section are the real manual — hub4com has no other. What you will find there:

  • GPS hub — the sharing recipe above, in the ReadMe’s own words.
  • COM port to telnet redirector — the com2tcp.bat example: an old DOS terminal program talking to a telnet server through a virtual pair.
  • RFC 2217 server and client — sharing a real port over the network, and consuming a shared port as a local virtual port.
  • Chat server — five telnet users on one hub, using the telnet filter and --route=All:All.
  • Multiplexing and encryption — several remote ports carried over one null-modem or TCP link, optionally encrypted with a shared secret phrase (via multiplexer.bat).
  • CVS proxy examples — period pieces from the SourceForge era; skip them unless you enjoy archaeology.

Each wrapper also documents itself: run any of the batch files with --help and it prints its own usage, options and defaults. The com2tcp.bat usage text, for example, lists its line settings (--baud, --data, --parity, --stop) with their defaults — the wrapper files are often more precise than the ReadMe about their own options.

The options you will actually meet first

  • --route=... — who hears whom; seen as --route=All:All in the testing and chat examples.
  • --octs=off — disable CTS handshaking on output for the port that follows it; the FAQ’s fix for a real port that receives nothing.
  • --use-driver=tcp — treat the following endpoints as TCP instead of serial; used by the chat-server and proxy examples.
  • --create-filter=... / --add-filters=... — build a filter and attach it to ports; the telnet and pinmap filters appear throughout the examples.
  • --load=... — read the hub’s arguments from a file instead of the command line; the FAQ shows how the wrappers use it, and it is how long configurations stay manageable.

That short list, plus the wrapper usages, covers the overwhelming majority of hub4com command lines in the wild. Resist copying longer configurations from old forum posts until you can say what each option does — most of them were written for a specific modem-signal problem that you may not have.

When the hub is not the tool

Two applications, one pair, nothing shared? Plain com0com is enough — no hub required. One port sent to one network address? That is com2tcp’s job, in its modern wrapper form. A remote port that must behave like a local one, modem signals and all? That is RFC 2217. The hub earns its place when more than two endpoints, or any modification of the stream, enter the picture. And when the problem is the driver underneath rather than the routing on top, the troubleshooting hub is the right starting point.

hub4com rewards a few minutes of reading more than hours of guessing: three concepts — ports, routing, filters — explain every example the project ships. Start from the hub page for the download and the recipe index, run the four-step test, and then adapt the GPS pattern to whatever device you actually need to share.

Similar Posts

Leave a Reply

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