shutdown TCP
Shut down a socket's send and/or receive operations.
Files
net_bsd.h/net_bsd.c
Prototype
int shutdown (int sock_id, int type);
Arguments
sock_id
Socket descriptor/handle identifier of socket to shut down.
type
Indicates which operation(s) to shut down:
SHUT_RD
The read-half of the socket is to be closed. No new data can be Rx'd on the socket and any data currently present in the receive queue is discarded. Any new data received is [ACK]'ed internally by TCP and quietly discarded. However, data may still be transmitted through the socket.
SHUT_WR
The write-half of the socket is to be closed; which is equivalent to performing a half-close on the TCP connection. No further data can be sent through this socket. If the socket transmit queue is not empty, its contents will be sent followed by a [FIN, ACK] frame.
SHUT_RDWR
Socket is closed on both directions. uC/TCP-IP does NOT keep a reference counter for the socket descriptor, thus calling shutdown() passing the SHUT_RDWR parameter is equivalent to calling close().
Returned Values
0, if no error.
-1, otherwise.