1.2.3.1.43 TCPIP_TCP_ServerOpen Function

C

TCP_SOCKET TCPIP_TCP_ServerOpen(
    IP_ADDRESS_TYPE addType, 
    TCP_PORT localPort, 
    IP_MULTI_ADDRESS* localAddress
);

Description

Provides a unified method for opening TCP server sockets.

Sockets are created at the TCP module initialization, and can be claimed with this function and freed using TCPIP_TCP_Close.

Preconditions

TCP is initialized.

Parameters

ParametersDescription
addTypeThe type of address being used. Example: IP_ADDRESS_TYPE_IPV4.
localPortTCP port to listen on for connections.
localAddressLocal address to use. Use 0 if listening on any network interface.

Returns

  • INVALID_SOCKET - No sockets of the specified type were available to be opened.

  • TCP_SOCKET handle - Save this handle and use it when calling all other TCP APIs.

Remarks

Sockets and user threads protection For efficiency reasons, there is NO PROTECTION for each individual API call except to Open and Close sockets! What it means is that:

  • The user application should close all its sockets before issuing a stack/if down command The stack manager takes care of the internally used sockets

  • A socket can NOT be used concurrently from multiple threads! It's ok to pass a socket from one thread to another as long as there's is no access from more than one thread at a time