UDP Client

UDP Client

There are also two methods for making a UDP connection to another server. The first method uses the
OPEN
command, while the second method uses the
CLIENTSOCKET
method. UDP is a one way communication medium, thus, you can only use output commands. Because UDP is connectionless, the output will be queued up until an
EOT
character is written or the maximum packet size is exceeded. Once the
EOT
character is written, the packet is formatted and sent.
With UDP, it is important to be careful about understanding what the network being used will support.
In many cases, there will be a limit to the size of the packet that can be used, typically between 1000 and 1500 bytes, but some networks cut this down into the 500 to 600 byte range. To be safe, keep your packets less than 500 bytes.
UDP does not guarantee transmission. See UDP specifications for more details.
Example
Since
CLIENTSOCKET
is the preferred method, an example is shown below.
10 CLOSE ALL 20 LET INPORT = CLIENTSOCKET("UDP","192.168.0.1",22222) 30 LET EOT$ = CHR$(4) 40 PRINT #INPORT: "Packet #"; I; EOT$; 50 LET I = I + 1 60 SLEEP 1 70 GOTO 40