shutdown
Prototype:
#include <sys/socket.h>
int shutdown(int sockfd, int how);
General Description: Closes specific paths or directions of data flow. Socket connections, by default, are bidirectional. If you want to limit the flow to be read-only or write-only, shutdown closes the other half of the channel.
Return Value: Zero (0) if everything goes well. If an error occurs, you can find the cause in errno.
Parameters
sockfd The open socket descriptor.
how A flag indicating which half (or both) of channel to close:
  • 0 - Make the channel output only.
  • 1 - Make the channel input only.
  • 2 - Close both halves, functionally same as close().
This operates only on connected sockets.
Possible Errors
EBADF sockfd is not a valid descriptor.
ENOTSOCK sockfd is a file, not a socket.
ENOTCONN The specified socket is not connected.
Examples
int sockfd;
struct sockaddr_in addr;
sockfd = socket(PF_INET, SOCK_STREAM, 0);
bzero(&addr, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(DEST_PORT);
inet_aton(DEST_ADDR, &addr.sin_addr);
connect(sockfd, &addr, sizeof(addr));
if ( shutdown(sockfd, 1) != 0 )
    PANIC("Can't make socket input-only");

(c)Network Data Conversions