Communication Using Tcp; Program Example - Mitsubishi Electric FX5 User Manual

Melsec iq-f series, ethernet communication
Hide thumbs Also See for FX5:
Table of Contents

Advertisement

7.1

Communication Using TCP

TCP (Transmission Control Protocol) establishes a connection to a device with a port number, and performs reliable data
communication.
To perform socket communication using TCP, confirm the following in advance.
• IP address and port number of the target device
• IP address and port number of the CPU module
• Which side will open a connection, the target device or CPU module? (Active open or Passive open)
TCP connection
There are two types of open operation for TCP connection: Active open and Passive open.
Firstly, the device waiting for a TCP connection performs a Passive open at the specified port.
The other device performs an Active open by specifying the port number of the device which is waiting in Passive open state.
Through the above process, a TCP connection is established and communication is available.
■Active open
Active open is a TCP connection method, which actively opens a connection to the device that is passively waiting for a TCP
connection.
■Passive open
The following two types of Passive open methods are available for TCP connection.
TCP connection
Description
method
Unpassive
Allows a connection regardless of the IP address and port number of the connected device. (The IP address and port number of the
device connected can be acquired using the SP.SOCCINF instruction.)
Fullpassive
Allows a connection to the device only when the specified IP address and port number are met. A connection made by another device
that does not have the specified IP address and port number is automatically disconnected before communication.
The expressions of Active and Passive opens may vary according to the device.
• Active open: TCP connection initiating device, client, connecting side, etc.
• Passive open: TCP connection waiting device, server, listening side, etc.

Program example

Program example for Active open
The following shows the communication flow of an Active open.
Start
Open processing:
SP.SOCOPEN instruction
Was data transfer
completed?
NO
Send by SP.SOCSND
instruction or receive by
SP.SOCRCV instruction
7 SOCKET COMMUNICATION FUNCTION
72
7.1 Communication Using TCP
...
Specifies the port number of the communication target device that is
waiting for TCP connection and opens a connection by Active open
YES (Completed or disconnected by the communication target)
Close processing:
SP.SOCCLOSE instruction
End

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents