Javier Valcarce's Homepage

Access to Serial Port from Internet

Usage

Usage:

 server_rs232 <tcp_port> <serial_port>

For example:

 >server_rs232 1234 COM1
  Using serial port COM1
  Waiting for a connection on port tcp/1234... 

As a client we can use telnet or HyperTerminal

 >telnet IP <port>

Serial port configuration is 9600bps, 1 stop bit, 8 data bits and without parity bit, also abbreviated as 9600/8N1. If you want to change this, you can easily modify the source code.

Access to several serial ports

In order to have access to several serial ports we can execute several instances of the server, each one using a different port. Because the server is very small (15K) this would not have to consume a lot of memory.

 >server_rs232 2001 COM1 
 >server_rs232 2002 COM2 
 >server_rs232 2003 COM3 
 >server_rs232 2004 COM4 
 >...

SSH tunneling

The server does not offer any security mechanism, does not request user name/password nor encrypts data. If this is a problem then you can use SSH to encapsulate (SSH tunneling) the connection's data and to have an authentication mechanism. You need

ssh lets that a secure channel between two hosts be utilized by an external program. The tunnel starts at the client host host-a, passes throught an intermediate host host-x (access point to private network from Internet) and ends at final host host-b.

The command that does the job is

user@host-a:~$ ssh -f -N -L1234:host-b:5000 user@host-x
Password:

From now, each program that connects to local host (host-a) 1234 TCP port will be actually connecting to 5000 TCP port of host-b. If there is not intermediate host host-x then host-x is simply host-b

user@host-a:~$ ssh -f -N -L1234:host-b:5000 user@host-b
Password:
[ssh process goes background and the prompt returns inmediately]

user@host-a:~$ netcat localhost 1234
...

This page forms part of website https://javiervalcarce.eu