
IP Communication
189
NetLinx Programming Language Reference Guide
IP Communication
Clients and servers communicate via Internet Protocol (IP) using either a connection-oriented or
connection-less protocol.
Connection-oriented input/output (I/O) channels require a connection or virtual circuit to be established
between the client and server before data can be transmitted or received. Transmission Control Protocol
(TCP) is the transport protocol typically used for connection-oriented I/O. With TCP, delivery of the data
is guaranteed.
With connection-less I/O, a connection is not established between the client and server before data is
exchanged. Instead, the identity of the client and server is established each time data is sent or received.
This type of communication is usually recommended for applications that transfer only small amounts of
data. User Datagram Protocol (UDP) is the transport protocol used for connection-less I/O. With UDP,
delivery of the data is not guaranteed.
Both the client and server must be able to identify incoming and outgoing data for a particular
conversation. To achieve this, each application assigns a unique number to the conversation. This number
is the local port number. A local port is not a physical port but rather a virtual port that identifies the
source or destination for data exchanged during the conversation. Local ports are specific to either the
client or the server; they need not match across applications.
The application assigns the number for the local port - as opposed to letting the system assign it (for
instance, as the return value for
IP_CLIENT_OPEN
or
IP_SERVER_OPEN
) - to satisfy the static nature
of
DEFINE_EVENT
handlers. All event handlers must specify a device, port, and system to identify the
events' source. This device information must be constant; that is, it cannot change at run-time. A constant
IP device specification can be defined using a local port number. For example:
Device Number = 0 The master
Port = LocalPort The local port number
System = 0 This system (where the application is running)
A range of numbers is reserved for local port numbers to make sure that this IP device-naming
convention does not interfere with future naming schemes. The program can only assign local port
numbers at or above the value of the keyword,
FIRST_LOCAL_PORT
. All port numbers below
FIRST_LOCAL_PORT
are reserved for future use. For example:
DEFINE_CONSTANT
PORT_REMOTE_MASTER1 = FIRST_LOCAL_PORT
PORT_REMOTE_MASTER2 = FIRST_LOCA 1
PORT_REMOTE_MASTER3 = FIRST_LOCA 2
Client Programming
Initiating a conversation
To initiate a conversation with a server, the client must use the
IP_CLIENT_OPEN
command and supply
either the IP address or domain name of the server and a port number for the requested service. The
client must also specify a local port number to use for sending and receiving data. This number
represents a virtual port on the client machine; it is not the actual port number used to create the client-
end socket. A local port number may not be used in another call to
IP_CLIENT_OPEN
until
IP_CLIENT_CLOSE
is called for that port number. The syntax is shown below:
IP_Client_Open(LocalPort, ServerAddress, ServerPort, Protocol)
Parameters:
Содержание NETLINX PROGRAMMING LANGUAGE
Страница 15: ...Table of Contents xiii NetLinx Programming Language Reference Guide...
Страница 16: ...xiv NetLinx Programming Language Reference Guide Table of Contents...
Страница 18: ...Introduction 2 NetLinx Programming Language Reference Guide...
Страница 76: ...Language Elements 60 NetLinx Programming Language Reference Guide...
Страница 106: ...Combining Devices Levels and Channels 90 NetLinx Programming Language Reference Guide...
Страница 112: ...Master To Master M2M 96 NetLinx Programming Language Reference Guide...
Страница 114: ...Mainline 98 NetLinx Programming Language Reference Guide FIG 1 Message and Mainline Processing in the NetLinx System...
Страница 182: ...Reserved Identifiers 166 NetLinx Programming Language Reference Guide...
Страница 204: ...NetLinx UniCode Functions 188 NetLinx Programming Language Reference Guide...
Страница 244: ...Appendix B Glossary 228 NetLinx Programming Language Reference Guide...
Страница 245: ...Appendix B Glossary 229 NetLinx Programming Language Reference Guide...