9. Program
9.1.2. TCP Socket Communications with Socket Service Instructions
This section explains the TCP socket communications performed by using the TCP socket
service function blocks (hereinafter referred to as socket service instructions) and outlines
the general operation of the send/receive message.
Additional Information
For details, refer to
Communications Instructions
in
Section 2 Instruction Descriptions
of the
NJ-series Instructions Reference Manual
(Cat. No. W502).
●
TCP Socket Services with Socket Service Instructions
This program uses the following 5 types of standard instructions to perform socket
communications.
Name
Function blocks
Description
Connect TCP
Socket
SktTCPConnect
Connects the TCP port of the destination device.
TCP Socket
Send
SktTCPSend
Sends data from a specified TCP socket.
TCP Socket
Receive
SktTCPRcv
Reads the data from the receive buffer for a
specified TCP socket.
Close TCP
Socket
SktClose
Closes a specified TCP socket.
Read TCP
Socket Status
SktGetTCPStatus
Reads the status of a specified TCP socket.
By using this instruction, this program checks if the
receive processing is completed at the receive
processing and checks the closing status at the
close processing.
*The socket obtained by the Connect TCP socket instruction (SktTCPConnect) is used as
an input parameter for another socket service instruction. The data type of Socket is
structure _sSOCKET. The specifications are as follows.
Variable
Meaning
Description
Data type
Valid range
Default
Socket Socket
Socket
_sSOCKET -
-
Handle
Handle
Handle for data
communications
UDINT Depends
on
data type
-
SrcAdr
Local
address
Local address *1
_sSOCKET_ADD
RESS
- -
PortNo Port
number
Port number
UINT
1 to 65535
IpAdr
IP address
IP address or host name
*2
STRING Depends
on
data type
DstAdr
Destination
address
Destination address *1
_sSOCKET_ADD
RESS
- -
PortNo Port
number
Port number
UINT
1 to 65535
IpAdr
IP address
IP address or host name
*2
STRING Depends
on
data type
*1: The address indicates an IP address and a port number.
*2: A DNS or Hosts setting is required to use a host name.
32
Summary of Contents for V750 series
Page 51: ...9 Program 2 Initialization processing 48...
Page 52: ...9 Program 49...
Page 53: ...9 Program 3 Connect processing 50...
Page 54: ...9 Program 4 Send processing 51...
Page 55: ...9 Program 5 Receive processing 52...
Page 56: ...9 Program 53...
Page 57: ...9 Program 6 Close processing 54...
Page 58: ...9 Program 7 Processing number error process 55...
Page 60: ...9 Program Program 57...
Page 62: ...9 Program Program 59...
Page 64: ...9 Program Program 61...
Page 78: ...2013 0911 P543 E1 01...