Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Open C Sockets: shutdown method

From Wiki
Jump to: navigation, search
Article Metadata
Created: polaka_sr (17 Jun 2008)
Last edited: hamishwillee (08 Feb 2012)

The shutdown method shuts down part of a full-duplex connection.

int shutdown (int sockfd, int how);

The shutdown system call causes all or part of a full-duplex connection on the socket associated with the file descriptor sockfd to be shutdown. The how argument specifies the type of shutdown. Possible values are:

  • SHUT_RD -- further receives will be disallowed.
  • SHUT_WR -- further sends will be disallowed.
  • SHUT_RDWR-- further sends and receives will be disallowed.

Following is the usage of shutdown function in Open C socket interface:

#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
TInt shutdown_example()
int sock_fd;
sockaddr_in addr,ss;
unsigned int len;
sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_ANY);
addr.sin_port = htons(5000);
shutdown(sock_fd, SHUT_RD)

Wiki Links

Open C Sockets Overview

This page was last modified on 8 February 2012, at 02:52.
50 page views in the last 30 days.