![background image](http://html.mh-extra.com/html/omron/sysmac-ny512-1300/sysmac-ny512-1300_user-manual_742451279.webp)
9-21
9 Socket Service
NY-series Industrial Panel PC / Industrial Box PC Built-in EtherNet/IP Port User’s Manual (W563)
9-
6 Det
ails on
Usin
g t
h
e Soc
ket Services
9
9-6-
4 UDP Sample Pro
gramming
3 :
// Request receiving data.
SktUDPRcv_instance(
Execute
:=TRUE,
Socket
:=WkSocket,
// Socket
TimeOut
:=UINT#0,
// Timeout value
Size
:=UINT#2000,
// Receive data size
RcvDat
:=RcvSocketDat[0]);
// Receive data
IF (SktUDPRcv_instance.Done=TRUE) THEN
Stage
:=INT#4;
// Normal end
ELSIF (SktUDPRcv_instance.Error=TRUE) THEN
Stage
:=INT#30;
// Error end
END_IF;
4 :
// Request closing data.
SktClose_instance(
Execute
:=TRUE,
Socket
:=WkSocket);
// Socket
IF (SktClose_instance.Done=TRUE) THEN
Stage
:=INT#0;
// Normal end
ELSIF (SktClose_instance.Error=TRUE) THEN
Stage
:=INT#40;
// Error end
END_IF;
0 :
// Normal end
DoSendAndRcv:=FALSE;
Trigger
:=FALSE;
ELSE
// Interrupted by error.
DoSendAndRcv:=FALSE;
Trigger
:=FALSE;
END_CASE;
END_IF;
Remote Node Programming
In this example, programming is also required in the remote node. The order of sending and receiv-
ing is reversed in comparison with the above procedure.
1
The SktUDPCreate instruction is used to request creating a UDP socket.
2
The SktUDPRcv instruction is executed to request reception. The receive data is stored in
RcvSocketDat[]
.
3
Execute the SktUDPSend instruction to request sending. The data in
SendSocketDat[]
is sent.
4
The SktClose instruction is executed to close the socket.
Summary of Contents for Sysmac NY512-1300
Page 459: ......