0% found this document useful (0 votes)
38 views3 pages

TCP Active Open Socket

This function block opens one of three available sockets and outputs the socket number. It requires an IP address, port number, and will return an error if all sockets are in use. When the EN input is on, it will send a request to open a socket. The opened socket number is output for use in other function blocks that require a socket number input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views3 pages

TCP Active Open Socket

This function block opens one of three available sockets and outputs the socket number. It requires an IP address, port number, and will return an error if all sockets are in use. When the EN input is on, it will send a request to open a socket. The opened socket number is output for use in other function blocks that require a socket number input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

(1/3)

Open_Socket TCP Active Open Socket


Basic function Request for open Socket 1, 2 or 3 and Output the opened Socket Number
Symbol

File name Open_Socket.cxf


Applicable CP1L-EL or CP1L-EM
models
Conditions for CX-Programmer Version 9.40 or higher
usage
Function TCP Active Open_Socket Function Block opens one of the three Sockets that is available and Outputs the
description opened Socket Number. If all three of the Sockets are occupied the No Sockets available flag will be high.
FB precautions Socket Number Output is a single Request to open Socket Value. The Socket Number Output is only reset
when a new Open Socket trigger is active.
EN input  Connect EN to condition for the FB to Work.
condition  Open Socket send the Request for Open an Available Socket.
 IP Address.
 Port Number.
Restrictions
Input 
variables
Output  This FB requires multiple cycles to process.
variables  The status of the Outputs bits are Reset if the OpenSocket bit is OFF.
Except the SocketNo Output.
(2/3)

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.

Modbus Portno = &502

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.

You might also like