RobotCore
Robot Core Documentation
Classes | Public Member Functions | List of all members
robotCore.Network Class Reference

The Network class handles network connections. More...

Classes

interface  NetworkReceiver
 The NetworkReceiver interface provides a callback for received data on a network connection. More...
 

Public Member Functions

void Connect (NetworkReceiver receiver, String host, int port, int retryTime)
 
void Connect (NetworkReceiver receiver, String host, int port)
 
void SendMessage (String message)
 
void Listen (NetworkReceiver receiver, int port)
 
void CloseConnection ()
 

Detailed Description

The Network class handles network connections.

Author
John Gaby

This class handles network connections. You can choose to either connect to a specified IP address or to listen for incoming connections of a specified port.

In either case, a two way connection is established. The receiver end of the connection is handled via a separate thread and there is a callback provided when data is received.

The transmit side runs in whatever thread the calling function is using.

Member Function Documentation

◆ Connect() [1/2]

void robotCore.Network.Connect ( NetworkReceiver  receiver,
String  host,
int  port 
)

This function attempts to connect to the specified host. If the connection fails, it will retry the connection. If the connection succeeds, a thread will be started that will retrieve any data sent over the connection and pass that data on to a handler via the NetworkReceiver interface.

It uses the default retry time of 5000 ms.

Parameters
receiver- Specifies class that will receive data from the connection
host- Specifies the host IP address
port- Specifies the host port number

◆ Connect() [2/2]

void robotCore.Network.Connect ( NetworkReceiver  receiver,
String  host,
int  port,
int  retryTime 
)

This function attempts to connect to the specified host. If the connection fails, it will retry the connection. If the connection succeeds, a thread will be started that will retrieve any data sent over the connection and pass that data on to a handler via the NetworkReceiver interface.

Parameters
receiver- Specifies class that will receive data from the connection
host- Specifies the host IP address
port- Specifies the host port number
retryTime- Specifies the amount of time in milliseconds to retry failed connections

◆ Listen()

void robotCore.Network.Listen ( NetworkReceiver  receiver,
int  port 
)

This function will start a new thread which will listen on the specified port for an incoming connection. Once the connection is made, it will retrieve any data sent over the connection (using the created thread) and pass that data on to a handler via the NetworkReceiver interface.

Parameters
receiver- Specifies class that will receive data from the connection
port- Specifies the port to listen on

◆ SendMessage()

void robotCore.Network.SendMessage ( String  message)

This function sends the specified string via the connection if the connection is open.

Parameters
message- Specifies message to be sent

The documentation for this class was generated from the following file: