Synopsis
void ctl_tcp_close_socket(CTL_SOCKET_t soc,
                          CTL_TCP_SOCKET_CLOSE_TYPE_t linger,
                          CTL_TIME_t timeout);
Description

ctl_tcp_close_socket closes the socket soc. Closing can be either graceful or hard. A graceful shutdown involves invoking the three-way FIN handshake with the remote TCP after all outgoing data has been sent. A hard shutdown merely closes socket soc at the local end—any further packets from the socket's remote partner are NAKed with a reset response.

linger timeout Type of close Wait for close?
CTL_TCP_CLOSE_DONTLINGER Don't care Graceful No
CTL_TCP_CLOSE_LINGER Zero Hard No
CTL_TCP_CLOSE_LINGER Nonzero Graceful Yes

ctl_tcp_close_socket should not be invoked from the network task with CTL_TCP_CLOSE_LINGER and a non-zero timeout value. In other words, do not use the blocking version of this function in a UDP or TCP callback.

See Also

ctl_tcp_shutdown