Networking Definitions and Classes

Table 19-24 summarizes the terms and abbreviations used by the network software and this documentation:

Table 19-24: Concept Definitions

Concept Description

Client

A TCP or UDP Endpoint. A TCP Client connects to a Server and then issues requests to that Server. Normally a TCP Client does not receive data except in response to a request. A UDP Client sends to and receives from other UDP clients.

Datagram

A unit of data that includes source and destination Endpoint information.

Endpoint

The source or destination for a datagram normally specified as an IP Address and Port.

IP

Internet Protocol - A low-level datagram protocol that is the basis for both TCP and UDP.

IP Address

A 32-bit number that identifies a particular network and computer on that network. Normally written as four decimal numbers, each of which range from 0 to 255, separated by periods. For example: 192.168.0.1

Port

A number from 0 to 65536 that identifies a process or protocol on a networked computer. Some ports are pre-assigned to particular protocols. For example, port 21 is normally used by a FTP server.

Server

A TCP Endpoint that accepts connections from a Client and services requests from a Client. Normally a Server does not initiate I/O but simply responds to requests. A UDP-based server uses the same methods as a client since there is no connection established.

Socket

An Object that holds connection information for network I/O. Various methods associate Endpoints with Sockets.

TCP

Transmission Control Protocol - A connection-based protocol that sends reliable Datagrams between Client and Server Endpoints. Messages are guaranteed to be delivered in order.

UDP

User Datagram Protocol – A connection-less protocol that sends Datagrams between two endpoints, without any guarantee of delivery or ordering. UDP is generally faster than TCP, but not as reliable.

 

GPL supports TCP Server and Client connections, as well as sending or receiving UDP datagrams. Table 19-25 summarizes the classes for network I/O.

Table 19-25: Networking Class Definitions

Networking Class Description

IPEndPoint

Objects of this class describe IP Endpoints.

Socket

Objects of this class correspond to local network Endpoints. Most network I/O operations are methods of the Socket class.

TcpClient

Objects of this class correspond to TCP Clients that can request connections to a TCP Server.

TcpListener

Objects of this class correspond to TCP Servers that can accept connection requests from TCP clients.

UdpClient

Objects of this class correspond to UDP Endpoints. They can exchange UDP Datagrams with other UDP Endpoints.

 

Table 19-26 through Table 19-30 summarize the methods and properties for each of the classes.  Each of these properties and methods is described in detail in the GPL Dictionary contained in the Software Reference section of the PreciseFlex Library.

Table 19-26: IPEndPoint Member Definitions

IPEndPoint Member Type Description

New IPEndPoint

Constructor Method

Creates an Endpoint and allows the IP Address and Port to be specified.

ipendpoint_obj.IPAddress    

Property

Sets or gets the IP Address of an Endpoint.

ipendpoint_obj.Port

Property

Sets or gets the Port of an Endpoint.

 

Table 19-27: Socket Member Definitions

Socket Member Type Description

socket_obj.Available

Property     

Gets the number of data bytes currently available to receive from a Socket.

socket_obj.Blocking

Property

Sets or gets the blocking mode for a Socket. If True, the Socket blocks.  If False, it does not block.

socket_obj.Close

Method

Closes any connections associated with a Socket.

socket_obj.Connect

Method

Requests a TCP Client connection with a remote TCP Server.

socket_obj.KeepAlive

Property

Sets or gets the flag that controls whether a keep-alive message is automatically transmitted over the current TCP connection.

socket_obj.Receive

Method

Receives a datagram from an open TCP connection.

socket_obj.ReceiveFrom

Method

Receives a datagram from an open UDP connection.

socket_obj.ReceiveTimeout

Property

Sets or gets the receive timeout, in milliseconds, for a Socket.

socket_obj.RemoteEndPoint

Property

Gets information about the remote end point of a TCP connection.

socket_obj.Send

Method

Sends a datagram on an open TCP connection.

socket_obj.SendTimeout

Property

Sets or gets the send timeout, in milliseconds, for a Socket.

socket_obj.SendTo

Method

Sends a datagram to an open UDP connection.

 

Table 19-28: TcpClient Member Definitions

TcpClient Member Type Description

New TcpClient

Constructor Method

Creates an Object for a TCP Client and optionally requests a connection.

tcpclient_obj.Client               

Method

Returns the embedded Socket for performing I/O.

tcpclient_obj.Close

Method

Closes a Client Socket and breaks any connection.

 

Table 19-29: TcpListener Member Definitions

TcpListener Member Type Description

New TcpListener

Constructor Method

Creates an Object for a TCP Server to listen for connections.

tcplistener_obj.AcceptSocket

Method

Accepts a connection and returns a new Socket Object for use by the TCP Server.

tcplistener_obj.Close

Method

Stops listening and closes the listener Socket.

tcplistener_obj.Pending

Property

True if there is a pending connection and AcceptSocket will succeed. Otherwise False.

tcplistener_obj.Start

Method

Starts listening for connection requests.

tcplistener_obj.Stop

Method

Stops listening and closes the listener Socket. Same as Close method.

 

 

Table 19-30: UdpClient Definitions

UdpClient Member

Type

Description

New UdpClient

Constructor Method

Creates an Object for I/O using UDP.

udpclient_obj.Client               

Method

Returns the embedded Socket for performing I/O.

udpclient_obj.Close

Method

Closes a Socket.

 

All network-related I/O is performed using Socket Objects.   TcpClient, TcpListener, and UdpClient Objects contain internal Socket Objects that are created by their constructors or methods. These Socket Objects are returned by the methods tcpclient_object.Client, tcplistener_object.AcceptSocket, and udpclient_object.Client. It is not useful to create a Socket object using New.