z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


close()

z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
SC27-3660-00

The close() call shuts down the socket associated with the socket descriptor s and frees resources allocated to the socket. If s refers to an open TCP connection, the connection is closed. If a stream socket is closed when there is input data queued, the TCP connection is reset, not cleanly closed.

If you specify 0 on SO_LINGER on the setsockopt() call, the data is canceled and the CLOSE is immediately returned. If you do not specify a value for SO_LINGER on the setsockopt() call, the CLOSE returns and TCP/IP tries to immediately resend the data.

Note: Issue a shutdown() call before issuing a close() call for any socket.
#include <manifest.h>
#include <socket.h>
int close(int s)
Parameter
Description
s
Descriptor of the socket to be closed

Return values

The value 0 indicates success; the value -1 indicates an error. Errno identifies the specific error.
Errno
Description
EBADF
The s parameter is not a valid socket descriptor.

Related calls

accept(), getsockopt(), setsockopt(), socket()

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014