When multiple clients are connected simultaneously to the same port, multiple TCP_Connection
instances are created. The hServer handle acquired by one TCP_Server is set to the multiple
TCP_Connection instances.
Example: When two clients are connected simultaneously to the same port
Declaration section
iServer: NBS.TCP_Server;// TCP_Server instance
iConnection: ARRA
Y [0..1] OF NBS.TCP_Connection; // TCP_Connection instance (two
instances)
Implementation section
iServer( xEnable:=TRUE , ipAddr:=ipAddr , uiPort:=uiPort ); // Server opened
// Omitted (Waiting for TCP_Server completion)
iConnection[0]( xEnable := TRUE , hServer := iServer.hServer ); // For 1st client
iConnection[1]( xEnable := TRUE , hServer := iServer.hServer ); // For 2nd client
■
UDP processing example
An example of processing for data transmission / reception via UDP is as follows:
This processing example assumes the following operating environment.
Processing for data transmission / reception
The processing for data transmission / reception is as follows:
●
Port open processing
● Reception start processing
● Transmission processing
Explanation of variables
Process
When the value is rewritten, the following processing is executed. After the execution is
completed, the variable is set to 0 (invalid value).
1 = Port open processing
2 = Reception start processing
3 = Transmission processing
MyipAddr
The IP address of the local unit is set.
MyPort
The port number of the local unit is set.
SendAddr
The IP address of the destination unit is set.
SendPort
The port number of the destination unit is set.
SendData
Data to be sent is set.
13.2 General-purpose Communication
WUME-GM1RTXOP-01 13-15