Sockets Programming Interfaces
3-32
Close One Half of a Connected Socket
shutdown
Syntax
int shutdown( int s, int how );
Parameter(s)
s
Socket
how
Manner of shutdown
Return Value
If it succeeds, the function returns 0. Otherwise, a value of –1 is returned and
the function fdError() can be called to determine the error:
EBADF
The file descriptor (socket) is invalid.
ENOTSOCK
The file descriptor does not reference a socket.
ENOTCONN
The specified socket is not connected.
Description
The shutdown() function causes all or part of a full-duplex connection on the
socket associated with a socket to be shut down. If how is SHUT_RD (0), fur-
ther receives will be disallowed. If how is SHUT_WR (1), further sends will be
disallowed. If how is SHUT_RDWR (2), further sends and receives will be dis-
allowed.
Creates a Socket
socket
Syntax
int socket( int domain, int type, int protocol );
Parameter(s)
domain
Socket domain (PF_INET)
type
Socket type (SOCK_DGRAM, SOCK_STREAM,
SOCK_RAW)
protocol
Socket protocol (Normally IPPROTO_TCP or
IPPROTO_UDP, but can be anything when type is set to
SOCK_RAW)
Return Value
If it succeeds, the function returns a file descriptor representing the socket.
Otherwise, a value of –1 is returned and the function fdError() can be called
to determine the error:
EPFNOSUPPORT
The specified domain was not PF_INET.
EPROTOTYPE
The type parameter does not support the
protocol parameter.
ESOCKTNOSUPPORT
The specified socket type is not supported.
ENOMEM
Memory allocation error allocating socket
buffers.
EMFILE
The descriptor table is full.
Description
The socket() function creates a socket, an endpoint for communication and re-
turns the socket in the form of a file descriptor.
The domain parameter specifies a communications domain within which com-
munication will take place; this selects the protocol/address family that should