shutdown (2)
Leading comments
Copyright (c) 2007 Bruce M. Simpson. Copyright (c) 1983, 1991, 1993 The Regents of the University of California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notic...
NAME
shutdown - disable sends and/or receives on a socketLIBRARY
Lb libcSYNOPSIS
In sys/types.h In sys/socket.h Ft int Fn shutdown int s int howDESCRIPTION
The Fn shutdown system call disables sends or receives on a socket. The Fa how argument specifies the type of shutdown. Possible values are:- SHUT_RD
- Further receives will be disallowed.
- SHUT_WR
- Further sends will be disallowed. This may cause actions specific to the protocol family of the socket Fa s to happen; see Sx IMPLEMENTATION NOTES .
- SHUT_RDWR
- Further sends and receives will be disallowed. Implies SHUT_WR
If the file descriptor Fa s is associated with a SOCK_STREAM socket, all or part of the full-duplex connection will be shut down.
IMPLEMENTATION NOTES
The following protocol specific actions apply to the use of SHUT_WR (and potentially also SHUT_RDWR ) based on the properties of the socket associated with the file descriptor Fa s .- Domain Ta Type Ta Protocol Ta Return value and action
- PF_INET Ta SOCK_DGRAM Ta IPPROTO_SCTP Ta Return -1.
- The global variable errno will be set to Er EOPNOTSUPP .
- PF_INET Ta SOCK_DGRAM Ta IPPROTO_UDP Ta Return 0.
- ICMP messages will not be generated.
- PF_INET Ta SOCK_STREAM Ta IPPROTO_SCTP Ta Return 0.
- Send queued data and tear down association.
- PF_INET Ta SOCK_STREAM Ta IPPROTO_TCP Ta Return 0.
- Send queued data, wait for ACK, then send FIN.
- PF_INET6 Ta SOCK_DGRAM Ta IPPROTO_SCTP Ta Return -1.
- The global variable errno will be set to Er EOPNOTSUPP .
- PF_INET6 Ta SOCK_DGRAM Ta IPPROTO_UDP Ta Return 0.
- ICMP messages will not be generated.
- PF_INET6 Ta SOCK_STREAM Ta IPPROTO_SCTP Ta Return 0.
- Send queued data and tear down association.
- PF_INET6 Ta SOCK_STREAM Ta IPPROTO_TCP Ta Return 0.
- Send queued data, wait for ACK, then send FIN.
RETURN VALUES
Rv -std shutdownERRORS
The Fn shutdown system call fails if:- Bq Er EBADF
- The Fa s argument is not a valid file descriptor.
- Bq Er EINVAL
- The Fa how argument is invalid.
- Bq Er EOPNOTSUPP
- The socket associated with the file descriptor Fa s does not support this operation.
- Bq Er ENOTCONN
- The Fa s argument specifies a SOCK_STREAM socket which is not connected.
- Bq Er ENOTSOCK
- The Fa s argument does not refer to a socket.