Open the TCP socket. Use family type: SL_AF_INET for IPv4, and SL_AF_INET6 for IPv6. The socket is the public socket of the server.
Bind the public port of the server. The host application must set a specific port for the server to allow clients to connect.
Listen. This stage marks the socket as a server socket. When listen is called, an additional socket is allocated for this specific server socket to reserve a socket for the next client connection (from this point the server socket is ready to accept new connections even if the host still did not call to sl_Accept).
Accept a client connection. This step extracts a connection request from the queue of pending connections on the server socket, and creates a new connected socket for data exchange between the server and the client side. The original public socket is not affected by this call, and an additional accept could be called on the public socket to accept additional clients. Each newly created client decreases the number of available sockets in the system by one. IPv6 server sockets bound to any interface, can accept IPv6 and IPv4 clients. When accepting IPv4 clients, the returned client IP address is IPv4 mapped to IPv6 format (for example, :00:ffff:ipv4).
Send and receive the data. Use the master socket descriptor to send and receive data. This step is done in the same way as in a secondary socket.
Close the data socket. To close a connection with a specific client, the close operation should be called with the client socket. The close is performed in a similar way to closing a client socket. For more information regarding linger, see the close section of client socket.
Close the server socket. When there is no need to accept any new client connections, call the close API on the server socket. The client sockets are not affected by closing the public socket, and only new connections cannot be accepted. If the host application is required to close the clients and the server, TI recommends closing the client sockets first.