shutdown

Ends all or part of a full-duplex connection.

Library:LibC
Standard:BSD
Service:Networking

Syntax

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

Parameters

s

(IN) Specifies the socket file handle on which the connection is to be ended.

how

(IN) Specifies the extent to which the connection is to be ended with one of the following flags:

Flag

Value

Description

SHUT_RD

0

Disables further receive operations.

SHUT_WR

1

Disables further send operations.

SHUT_RDWR

2

Disables both send and receive operations.

Return Values

If successful, returns 0. Otherwise, returns -1 and sets errno to one of the following:

Decimal

Constant

Description

4

EBADF

The socket parameter is not a valid handle.

38

ENOTSOCK

The socket parameter does not reference a socket handle.

57

ENOTCONN

The specified socket is not connected.

Remarks

The shutdown function ends all or part of a full-duplex connection on the socket associated with s.

If how is 0 (disable receive), you cannot subsequently call recv. If how is 1 (disable send), you cannot call send again. If how is 2 (disable send and receive), you cannot subsequently call send or recv.

See Also

connect