Serial tcp forwarding

Hi, everybody!

I have two machines with openSUSE 11.1 (default, no updates). How can I connect /dev/ttyS0 on both machines over tcp?


What you want is to set up PPP over the serial line connection. Here’s a howto. It’s old because people don’t do this much anymore.


Could you not put an Ethernet card in each computer and use a crossover cable? The slow rate of a serial line would drive you mad I would think. E.g. 115200 bps = 14.4kB/s = over a minute to transfer 1MB.

Here is my problem in details:

I have an openSUSE “terminal server” with NX Free Server (
And I have a client machine with the same config. Client machine have a Barcode Reader connected via rs232 (serial port).
NX server can’t forward serial port like RDP. So the one way is to forward it via TCP (client and server ar far away).
In windows a can do it (lot of soft), but not in linux.
I have tried “socat”, “remserial”, “serialoverip” and nothing.

Ah, well you should have said that in the beginning. This is not TCP over serial line, what you want is serial port forwarding.

Looks like you have already found the free software solutions mentioned here:

COM port redirector - Wikipedia, the free encyclopedia

What exactly is the problem you encounter with those programs? Usually they do not provide full emulation, you don’t get the modem handshake lines, etc, just the data stream. So if your program is expecting a real hardware port, it won’t be totally compatible.

Ken_yap, thanks for your support!

As I Said, Barcode Reader connected to the second machine on /dev/ttyS0. When I read a barcode I can simply see it localy with “#cat /dev/ttyS0”. When I connect it to the server, over VNC, for example, I need to forward local /dev/ttyS0 to the server. So then I read barcode localy and make “#cat /dev/ttyS0” on the server, I’ll be able to see the barcode.

I can’t do it with the soft, I wrote at the previous post.

P.S. Barcode is a simple string value.
P.S. Sorry for my English…

Yes, I understand your problem, but what I want to know is what goes wrong when you use one of the programs you named, for example remserial. What doesn’t work?

Good news, now I can successfully connect linux /dev/ttyS0 (linux as server) with Windows COM-port(windows as client). ser2net helps me, and it works good. Bur ser2net can only forward serial port into network.
Now I’m trying to make Windows PC as serial port server and connect it with linux machine over tcp.
remserial: ./remserial -d -r -p 2002 -s “9600 raw” /dev/ttyS0 &
remserial starts and I can see it in ProcessTable, but no communication.

Is it possible?
To install ser2net on both PCs and attach each to local device /dev/ttyS0 and tcp port 7000. If outgoing traffic on 7000 port of first PC exists then forward it to 7000 port of another PC?

You Could Try Netcat:
I guess is capable of doing what you need.

I think you need a program at each end. At the end with the real serial port you need a program to open the serial port and pass the data to a TCP stream. At the other end you need a program to connect to the TCP stream and pass the data to a pseudo-tty which can be opened by the application as if it were the real serial device.

One of those program should be a TCP server and the other a client. Which is which depends on what options are available with the program I suppose.

Thanks for help! I made it yesterday. All I need was “socat”.
On the client (that share BarCode reader to net):

socat tcp-l:7001,reuseaddr,fork file:/dev/ttyS0,raw,echo=0

On the server (who accept connection):

socat PTY,link=/dev/ttyS0,raw,echo=0 tcp4:<Server IP(Lan or Wan)>:7001

It works perfect) No disconnects in 12 hours.

Now I have 2 new questions:

  1. How to automate socat commands, to do them, until they can connect.
  2. How to remove limit of 3 sessions. 3 user can’t work on 1 machine at the same time. Check it by “Alt+Ctrl+F(1-4)” and login by different users, on the F3 I received, that “login name is incorrect”, but it is not true.

Wow, socat is a really big Swiss Army Knife. Thanks for the heads up. Might be useful some day.

You might want to run a shell script that calls socat out of /etc/inittab. It could try to connect and if it fails, it would sleep for a while and retry later. That way it would maintain the tunnel automatically.

Don’t know about the session thing.