Serial port and GPS

IPClient Class

Client implementation for the server in Serial2IP

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

System.Object
   serial.IPClient
      serial.IPClientGPS

[Visual Basic]
Public Class IPClient
[C#]
public class IPClient

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.

Remarks

Reads information from the server and calls callbacks for lines read.

Example

Create a simple TCP/IP client implementation to localhost on port 5000 and printing all incoming text lines to the standard output:

[C#]
using System;
using System.Collections;
using serial;

public class IPClientTest {
  private static void readline(ArrayList arr) {
    foreach(object o in arr) {
      Console.WriteLine(o);
    }
  }

  public static void Main() {
    IPClient clnt;
    clnt = new IPClient();
    clnt.RdLineCb = new ReadLineDelegate(IPClientTest.readline);
    clnt.oper(ServerType.TCP, "localhost", 5000);
  }
}
Compile the code using for example
csc -out:test.exe IPClient.cs IPClientTest.cs Utils.cs
gmcs -out:test.exe IPClient.cs IPClientTest.cs Utils.cs
Then obtain a server, like netcat or netcat for Windows and bring it to act as a TCP server listening on port 5000 and slowly sending a content of a large text file:
 netcat -i 1 -l -p 5000 < largefile.txt
then start the client using test.exe or mono test.exe and watch the contents of largefile.txt coming through TCP. You can also configure the client for example for listening to UDP broadcast messages using ServerType.BCAST by the call to IPClient.oper() and feed the client from netcast using this time
netcat -i 1 -u 255.255.255.255 5000 < largefile.txt
The client may also communicate with UDP servers, s2ip.exe may also act as an UDP server. In this case the client sends first anything (byte 0) to the server in order to let the server discover the UDP port of the client, on which the client listenes for answers from the server.

Requirements

Namespace: serial

Assembly: sg (in sg.exe)

See Also

IPClient Members | serial Namespace