Receiving Data; Sending Data; Receiving Data With Udp - AMX NETLINX PROGRAMMING LANGUAGE Manual

Programming language
Table of Contents

Advertisement

Receiving data

To receive data from a client, use a
CREATE_MULTI_BUFFER
object. The syntax:
Data_Event[Device]
{
STRING:
{
}
}
Parameters:

Sending data

To send data to the client, use the
SEND_STRING 0:LocalPort:0, '<string>'
The device specification (0:LocalPort:0) is interpreted as follows:

Receiving Data with UDP

Since UDP is connection-less, no formal agreement has been made between the client and server to
exchange data. The client simply sends a UDP message and hopes the server is listening. In many
protocols that use UDP for communication, there is an implied agreement for the client to receive date
from the server.
When a UDP client socket in created, the socket is assigned a UDP/IP port number, not to be confused
with local port. This UDP/IP port will be used to send UDP messages. The server, if listening, will
receive this message along with the IP address and UDP/IP of the client who sent the message.
Some UDP protocols have an implied agreement that the server will be able to respond to the client by
sending a response back to the IP address and UDP/IP from where the message originated. Although the
UDP protocol does not specify that the client must expect to receive messages in this way, many UDP/IP
require the client to listening for response after sending a message.
Netlinx has two UDP client implementations. These are UDP (2) and UDP With Receive (3). The first
implementation only sends message and cannot receive messages. UDP with Receive will send and
receive messages on a single UDP/IP port.
It may seem like UDP (2) is not needed; however, it still serves and important purpose. Image you
wanted to send a UDP message and expect a response. The proper way to open this type of socket,
assuming you want to send a UDP message to 192.168.0.1 on UDP/IP port 6000, is:
IP_CLIENT_OPEN(dvUDPClient,'192.168.0.1',6000, IP_UDP_2WAY)
Now, if you were also writing the code for 192.168.0.1, you would need to have opened a UDP server
using the following:
IP_SERVER_OPEN(dvUDPServer,6000,IP_UDP)
NetLinx Programming Language Reference Guide
DATA
. If an event handler is used, the data is located in the
// process incoming string (Data.Text)
Device is (or contains as part of an array) the device representing the conversation
(0:LocalPort:0).
SEND_STRING
Device Number: 0: The master
Port: LocalPort: The local port number
System: 0: This system (the client)
event handler or a buffer created with
command.
IP Communication
or
CREATE_BUFFER
field of the
Text
DATA
193

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Netlinx studio 2

Table of Contents