62
1 FUNCTIONS
1.4 Socket Communications
Communications using TCP/IP
TCP/IP protocol establishes a connection between the external device's port number for reliable data exchange.
Check the following items before performing socket communications using TCP/IP.
• IP addresses and port numbers on external device side
• IP addresses and port numbers on the Ethernet-equipped module side
• Which side, the external device side or Ethernet-equipped module side, will open a connection (Active open or Passive
open)
TCP/IP connection operation
TCP/IP connection includes Active open and Passive open.
First, the side with the TCP/IP connection executes Passive open with the specified port number
The side with TCP/IP connection specifies the port number waiting in the Passive open side, and executes Active open.
This enables the TCP/IP connection, the connection is established, and data can be exchanged.
For details on Active open and Passive open, refer to the following.
( Page 378 TCP/IP communications)
The Active open and Passive open expression may differ according to the external device.
• Active open: TCP/IP connection side, client side, connect side, and others
• Passive open: TCP/IP connection wait side, server side, listen side, and others
■Active open
The following figure shows the flow of data exchange using Active open.
■Passive open
The following figure shows the flow of data exchange using Passive open.
⋅⋅⋅
YES
NO
Start
Open processing
Send by the SOCSND instruction, or receive by
the SOCRCV or SOCRCVS instruction.
Close processing
(Completed, or disconnected by the external device.)
Was data transfer
completed?
End
Specify the port number of the external device waiting for
TCP connection and open a connection by Active open.
⋅⋅⋅
YES
NO
Start
Waiting for TCP connection in Passive open state.
Send or receive?
Send by the SOCSND instruction, or receive by
the SOCRCV or SOCRCVS instruction.