TcpServer (FB)

FUNCTION_BLOCK TcpServer IMPLEMENTS ITcpServer

TCP server to open a Listen port where clients can conenct to
After the server has been setup via the TcpServer.Listen method, the TcpServer.Accept method must run cyclically.
An incoming connection will be accepted via the TCP stack and forwarded to IEC code via the TcpServer.Accept method.
The method will return the necessary information about the remote side in form of the socket address.

After accpeting the connection, the client information must be parsed to a TcpConnection instance via the TcpConnection.SetIntSocketAddr and its input SockAddrSetByExternal.
Additionally the socket handle has to be assigned to the TcpConnection via the attribute TcpConnection.Socket.
This is required in order to perform communication via this socket with the methods TcpConnection.Send, TcpConnection.Receive and TcpConnection.Close.

Hint

Communication can be done either via Standard Sockets (STD) or via TLS Sockets (TLS 1.2).

Hint

Each incoming connection must be overhand to a Tcp connection function block which handles the complete communication. To hand over the socket address, the method SetIntSocketAddr must be used.

Properties:

ServerState

Methods:

Listen

Accept

Close

Structure: