TCP Active Open Socket
TCP Active Open Socket
Application
example TCP Active Open_Socket Function Block is designed for use with the other Function Blocks.
The Socket Number Output can be used for the Socket Number Input used by :
- Fn03_ReadRegister
- Fn04_ReadInputRegister
- Fn05_ForceSingleCoil
- Fn06_WriteRegister
- Close_Socket
Example:
(3/3)
Variable Tables
Input Variables
Name Variable name Data type Defaul Range Description
t
EN EN BOOL 1 (ON): FB ON.
0 (OFF): FB OFF.
Open Socket OpenSocket BOOL Start request for open socket
IP address 1 IPaddress_1 INT &0 to &255 Specify the local IP address.
IP address 2 IPaddress_2 INT &0 to &255 For example 192.168.250.2:
IPaddress_1 = &192, IPaddress_2 = &168,
IP address 3 IPaddress_3 INT &0 to &255 IPaddress_3 = &250, IPaddress_4 = &2
IP address 4 IPaddress_4 INT &0 to &255
Local Port Number LocalPortNo UINT &0 to 65535 If port number 0 is specified the TCP
port number will be automatically
allocated and the number of the port
that was opened will be stored in the
local UDP/TCP port number in the
Socket Service Parameter Area (i.e.,
the actual port number will be
overwritten on the value of 0 set by the
user).
Do not specify the port being used as
the FINS UDP port (default: 9600), TCP
port numbers 20, 21 and 25.
As a rule, use port numbers 1,024 and
higher.
Remote Port Number RemotePortNo UINT &0 to 65535 When opening a passive TCP socket,
the combination of the remote IP
address and the remote TCP port
number can be used to affect
processing as shown in the table for the
Remote IP Address, above. If the
Remote UDP/TCP Port No. is set to 0,
the UDP/TCP port number of the
remote device will be written as the
Remote UDP/TCP Port No. in the
Socket Service Parameter Area.
Output Variables
Name Variable name Data type Range Description
ENO ENO BOOL 1 (ON): FB processed normally.
(May be omitted.) 0 (OFF): FB not processed or ended in an error.
No link NoLink BOOL No cable Connection
No Sockets NoSockets BOOL No Sockets Available
Done Done BOOL Done
Socket Number SocketNo UINT Opened Socket Number
Error Error BOOL Error
Error ID ErrorID UINT Error code:
TCP/UDP Error Codes
Ethernet Units Construction of Networks Operation
Manual (W420)
7-3 Command/Response Reference
FINS Error Codes
Communications Commands Reference Manual
(W342)
5-1-3 Error Codes
CP1L-EL/EM CPU Unit Operation Manual (W516)
12-1 Troubleshooting
Version History
Version Date Contents
1.00 21-03-2012 Original production
1.01 13-07-2012 Added Local Port Number.
Open Socket Request even if Storage Error Flag is ON for the socket.