#include <cafe.h>
#include <cafe/network.h>

int SOClose(int fd);


fd Descriptor of socket to close.

Return Values

0 upon success. Upon failure, returns -1 and errno is set appropriately.


SO_ELIBNOTREADY Socket library is not initialized.
SO_ENOMEM Insufficient memory in the stack.
SO_ENOTSOCK Specified argument is not a socket.
SO_EINVAL Invalid operation occurred in the stack.
SO_ENOTCONN Not connected.
SO_EALREADY There is already a previous blocked close call on the same socket.
SO_EBUSY Socket resource manager busy processing requests.
SO_EABORTED Indicates the operation was aborted. For example, this error can be returned for calls blocked on a socket after the socket is closed by another thread.
SO_EUNKNOWN Unknown error.
SO_ERANGEINVALID Internal API error, invalid error code.
SO_EAPIERROR Internal API error.
SO_ERROR Internal API error.


Closes the specified socket.

If there are threads blocking on a socket (for example, in a SOSend/SOSendTo or SORecv/SORecvFrom) and another thread closes the socket, the blocked threads will return from their blocked calls with an SO_EABORTED error code.

Do Not Call From

Callbacks Do not call this function from any callback function.
Interrupt handler Do not call this function from any interrupt handler.
Exception handler Do not call this function from any exception handler.

See Also


Revision History

2012/10/09 Added Errors section.
2012/08/16 Cleanup pass.
2011/02/21 Initial version.