IP Communication
190
NetLinx Programming Language Reference Guide
LocalPort
: A user-defined, non-zero integer value representing the virtual port on the client
machine that will be used for this conversation. This port number must be passed to
IP_CLIENT_CLOSE
to close the conversation.
ServerAddress
: A string containing either the IP address (in dotted-quad-notation) or the
domain name of the server to connect to.
ServerPort
: The port number on the server that identifies the program or service the client is
requesting.
Protocol
: The transport protocol to use (
1 = TCP, 2 = UDP
). If this parameter is not specified,
TCP (1) is assumed. The constants
IP_TCP
and
IP_UDP
can be used to specify this
parameter.
Terminating a conversation
To terminate a conversation, you must use the
IP_CLIENT_CLOSE
command and pass the number of
the local port used for the conversation. The syntax:
IP_Client_Close(LocalPort)
Parameters:
LocalPort
: A user-defined, non-zero integer value representing the virtual port on the client
machine that will be used for this conversation.
Sending data
To send data to the server, use the
SEND_STRING
command.
SEND_STRING 0:LocalPort:0, '<string>'
The device specification (0:LocalPort:0) is interpreted as follows:
Device Number: 0: The master
Port: LocalPort: The local port number
System: 0: This system (the client)
Receiving data
To receive data from the server, use a
DATA
event handler or a buffer created with
CREATE_BUFFER
or
CREATE_MULTI_BUFFER
. If an event handler is used, the data is located in the
Text
field of the
DATA
object. The syntax is shown below:
Data_Event[Device]
{
STRING:
{
// process incoming string (Data.Text)
}
}
Parameters:
Device
is (or contains as part of an array) the device representing the conversation
(0:LocalPort:0)
When using IP sockets in NetLinx, it is not uncommon to create a buffer using a
CREATE_BUFFER
keyword and processing the buffer in the
DATA_EVENT...OFFLINE
event.
Netlinx has an important behavior than can affect the performance of IP socket code. This is not a bug
but a feature. If you are aware of it, you can write your code to take maximum advantage of the speed
NetLinx offers.
Summary of Contents for NETLINX PROGRAMMING LANGUAGE
Page 15: ...Table of Contents xiii NetLinx Programming Language Reference Guide...
Page 16: ...xiv NetLinx Programming Language Reference Guide Table of Contents...
Page 18: ...Introduction 2 NetLinx Programming Language Reference Guide...
Page 76: ...Language Elements 60 NetLinx Programming Language Reference Guide...
Page 106: ...Combining Devices Levels and Channels 90 NetLinx Programming Language Reference Guide...
Page 112: ...Master To Master M2M 96 NetLinx Programming Language Reference Guide...
Page 182: ...Reserved Identifiers 166 NetLinx Programming Language Reference Guide...
Page 204: ...NetLinx UniCode Functions 188 NetLinx Programming Language Reference Guide...
Page 244: ...Appendix B Glossary 228 NetLinx Programming Language Reference Guide...
Page 245: ...Appendix B Glossary 229 NetLinx Programming Language Reference Guide...