Name

shutdown - shut down part of a full-duplex connection

Library

libc.lib

Synopsis

  #include <sys/types.h>
  #include <sys/socket.h>
  int shutdown (int sockfd, int how);

Return values

The shutdown() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

Detailed description

The shutdown system call causes all or part of a full-duplex connection on the socket associated with the file descriptor sockfd to be shut down. 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.

Examples

#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);
   bind(sock_fd,(sockaddr*)&addr,sizeof(addr));
   shutdown(sock_fd, SHUT_RD)
   close(sock_fd);
}

         

Errors

The shutdown system call fails if:
[EBADF]
  The s argument is not a valid file descriptor.
[EINVAL]
  The how argument is invalid.
[ENOTCONN]
  The socket is not connected.
[ENOTSOCK]
  The s argument does not refer to a socket.

See also

connect, socket
The shutdown system call is expected to comply with -p1003.1g-2000, when finalized.
The shutdown system call appeared in BSD 4.2. The SHUT_RD, SHUT_WR, and SHUT_RDWR constants appeared in -p1003.1g-2000.

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top