Serial port and GPS

Serial2IP Class

Copies information from the serial port to IP.

For a list of all members of this type, see Serial2IP Members.


[Visual Basic]
Public Class Serial2IP
    Inherits Serial
public class Serial2IP : Serial

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.


Copies information arriving at the serial port to IP, not vice versa. The class can act as a TCP or UDP server or it can broadcast the information to a specified UDP port. If the server is running as UDP, then the UDP client must initiate the connection by sending anything to the server. The class IPClient sends foe example a single byte 0.


TCP server, copying stream from the serial port COM4. Please be aware, that the serial port names are platform dependent, for example the 4th serial port on a desktop windows ma be called COM4: and on linux /dev/ttyS3. Use Serial.COMPORTS in order to list valid port names.

using Serial.IO.Ports;
using System;
using serial;
public static void serial2ipcopy() {
  Serial2IP s;
  s = new Serial2IP();
  s.PortName = "COM4";
  s.BaudRate = 9600; s.DataBits = 8;
  s.Parity = Parity.None; s.StopBits = StopBits.One;
  s.oper(ServerType.TCP, 5000);
  Console.Write("Hit ENTER to close"); Console.ReadLine();
  s.oper(ServerType.OFF, 0);
The stream generated by this server method can be retrieved for example using netcat localhost 5000 or telnet localhost 5000. The UDP server is started using parameter ServerType.UDP rather than ServerType.TCP for the call to s.oper(). In this case the stream from the server using for example echo anything | netcat -u localhost 5000. The broadcasting server is started using the parameter ServerType.BCAST and the stream from the server can be tested using netcat -l -p 5000. Netcat for unix systems can be downloaded from, netcat for windows - from The netcat executable for windows is named nc.exe rather than netcat.


Namespace: serial

Assembly: s2ip (in s2ip.exe)

See Also

Serial2IP Members | serial Namespace