2 Instruction Descriptions
2-774
NJ-series Instructions Reference Manual (W502)
z Programming in the Remote Node
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 SktTCPAccept instruction is used to request accepting a TCP socket.
2
The SktTCPRcv instruction is used to request receiving data. The received data is stored in
RcvSocketDat[].
3
The SktTCPSend instruction is used to request sending data. The data in SendSocketDat[] is
sent.
3 :
SktGetTCPStatus_instance(
Execute:=TRUE,
Socket :=WkSocket);
IF (SktGetTCPStatus_instance.Done=TRUE) THEN
Stage:=INT#4;
ELSIF (SktGetTCPStatus_instance.Error=TRUE) THEN
Stage:=INT#30;
END_IF;
4 :
SktTCPSend_instance(
Execute :=TRUE,
Socket :=WkSocket,
SendDat:=SendSocketDat[0],
Size :=UINT#2000);
IF (SktTCPSend_instance.Done=TRUE) THEN
Stage:=INT#5;
ELSIF (SktTCPSend_instance.Error=TRUE) THEN
Stage:=INT#40;
END_IF;
5 :
SktTCPRcv_instance(
Execute :=TRUE,
Socket :=WkSocket,
TimeOut:=UINT#0,
Size :=UINT#2000,
RcvDat :=RcvSocketDat[0]);
IF (SktTCPRcv_instance.Done=TRUE) THEN
Stage:=INT#6;
ELSIF (SktTCPRcv_instance.Error=TRUE) THEN
Stage:=INT#50;
END_IF;
6 :
SktClose_instance(
Execute:=TRUE,
Socket :=WkSocket);
IF (SktClose_instance.Done=TRUE) THEN
Stage:=INT#0;
ELSIF (SktClose_instance.Error=TRUE) THEN
Stage:=INT#40;
END_IF;
0 :
DoTCP:=FALSE;
Trigger :=FALSE;
ELSE
DoTCP:=FALSE;
Trigger :=FALSE;
END_CASE;
END_IF;
// Socket
// Normal end
// Error end
// Request closing.
// Normal end
// Interrupted by error.
// Socket
// Timeout time
// Receive data size
// Receive data
// Normal end
// Error end
// Request receiving data
// Socket
// Send data
// Send data size
// Normal end
// Error end
// Request sending data
// Request reading status.
// Socket
// Normal end
// Error end