SOCKET_ACCEPT

The SOCKET_ACCEPT instruction is for Transmission Control Protocol (TCP) connections only. Accepts a TCP connection request from a remote destination and returns a Socket Instance used to send and receive data on the newly created connection.
Operation details:
  • Before executing Socket_Accept, execute SOCKET_CREATE and specify the local port number for the accept connection.
  • Outputs are updated synchronously from the program scan.
Languages supported: Function block diagram, ladder diagram, structured text.
This instruction applies to the L20E, L50E, and L70E controllers.
SOCKET_ACCEPT
SOCKET_ACCEPT
SOCKET_ACCEPT parameters
Parameter
Parameter Type
Data Type
Description
Execute
Input
BOOL
Instruction block enable.
  • TRUE: Rising edge detected; start the instruction block with the precondition that the last operation has been completed.
  • FALSE: No rising edge detected; instruction block not started.
Instance
Input
UDINT
Identifies the socket instance. Copy the returned Socket Handler from the SOCKET_CREATE instruction.
Timeout
Input
UDINT
Timeout for the SOCKET_ACCEPT instruction block instances. The function block returns an Error if the timeout value is less than the minimum value.
Timeout range: 1000-86400000 milliseconds Set Timeout to 0 to use the default value 10000 (10 Second).
Done
Output
BOOL
Indicates when operation is complete.
  • TRUE: Operation completed successfully.
  • FALSE: Operation is in progress or encountered an error condition.
Output is updated synchronously from the program scan.
Busy
Output
BOOL
  • TRUE: The operation is not finished.
  • FALSE: The operation is finished.
Output is updated synchronously from the program scan.
Error
Output
BOOL
Indicates that an error occurred.
  • TRUE: An error is detected.
  • FALSE: No error.
Output is updated synchronously from the program scan.
Status
Output
SOCK_STATUS
Status is defined using the SOCK_STATUS data type which contains Socket error codes, SubErrorID, and Socket instruction status bits information.
Output is updated synchronously from the program scan.
AcceptInst
Output
UDINT
Contains the Accept Instance for this Socket Instance. Use the unique Accept Instance number with subsequent SOCKET_READ and SOCKET_WRITE for this connection.
Output is updated synchronously from the program scan.
AcceptAddr
Output
SOCKADDR_CFG
A data structure that contains the Accept Address for the socket.
For more information, refer to SOCKADDR_CFG data type.
To specify an IP address of 192.168.2.100 and Port = 12000:
  • AcceptAddr.IPAddress[0] = 192
  • AcceptAddr.IPAddress[1] = 168
  • AcceptAddr.IPAddress[2] = 2
  • AcceptAddr.IPAddress[3] = 100
  • AcceptAddr.Port = 12000
Output is updated synchronously from the program scan.

SOCKET_ACCEPT examples

SOCKET_ACCEPT function block diagram example
SOCKET_ACCEPT function block diagram example
SOCKET_ACCEPT ladder diagram example
SOCKET_ACCEPT ladder diagram example
SOCKET_ACCEPT structured text example
SOCKET_ACCEPT structured text example
Results - TCP server
Results - TCP server
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal