SOCKET_CREATE
Creates an instance of the socket and returns an instance number that is used as an input in any follow-on socket operations.
Operation details:
- Sockets instructions support full-duplex communication with remote devices.
- User Datagram Protocol (UDP) connections support a maximum of eight queued UDP datagrams packets. The queue contains the most recent packets.
- Micro820 controllers of revision 9 or later support up to eight Socket Instances. The Socket instances support UDP and TCP Sockets:
- Use all eight instances for client Transmission Control Protocol (TCP) connections.
- Use all eight instances to listen for incoming TCP connections, and then accept eight connections from other devices.
- Perform both TCP client and server operations.
- Perform both TCP and UDP operations.
- To accept incoming TCP connections to the same port, create a Socket Instance.
- TCP Connection Loss:
- User application program should detect the loss of TCP connections and handle the event. Depending on the user application, consider the option to Fault the controller.
- Fault the controller.
- Try to re-establish the connection.
- To re-establish communications with another device:
- Delete the Socket Instance for the lost connection.
- If the connection is a TCP client, create a Socket Instance using SOCKET_CREATE and execute SOCKET_OPEN to the target device.
- If the connection is a TCP server, create a Socket Instance using SOCKET_CREATE and execute SOCKET_ACCEPT to wait for another connection from the remote device.
- Application Messages for TCP connections:
- A TCP connection is a byte stream between two applications. The application protocol determines the message formats.
- Messages can be fixed size or variable size.
Languages supported: Function block diagram, ladder diagram, structured text.
SOCKET_CREATE

Parameter | Parameter Type | Data Type | Description |
---|---|---|---|
Execute | Input | BOOL | Instruction block enable.
|
Type | Input | USINT | Specify the Type of Socket:
|
SockAddr | Input | SOCKADDR_CFG | Specify the address configuration for the socket. The EtherNet/IP module to choose the local port number, set SockAddr to 0. Specify the local port number where an application is listening and receiving, or :
Local port range: From 1 through 65535. An error occurs if the specified local port number is already in use by the L20E or L50E controller. The controller uses the following port numbers: TCP Ports:
UDP Ports:
|
Timeout | Input | UDINT | Specify the Timeout for Socket inactivity. If a socket instance does not receive any requests within the specified inactivity timeout, the socket instance is deleted. If a request is sent after the sock instance is deleted an error, Socket instance not supported, is returned. The instruction block returns an error when the timeout value is less than the minimum value. Set Timeout so that it is longer than the longest interval between socket operations. If the inactivity Timeout is too short, socket instances might time out. Timeout range: 1000-86400000 milliseconds. Set Timeout to 0 to use the default value 300000 (5 minutes). |
Done | Output | BOOL | Indicates when operation is complete.
|
Busy | Output | BOOL |
|
Error | Output | BOOL | Indicates that an error occurred.
|
Status | Output | SOCK_STATUS | Status is defined using the SOCK_STATUS data type, which contains ErrorID, SubErrorID, and StatusBits information. |
Instance | Output | UDINT | Contains Socket Handler. Use the Instance parameter for subsequent Socket instructions. |
SOCKET_CREATE examples
SOCKET_CREATE function block diagram example

SOCKET_CREATE ladder diagram example

SOCKET_CREATE structured text example

Results - TCP client

Results - TCP server

Results - UDP

Provide Feedback