mtcp_close
NAME
mtcp_close − close an mTCP socket descriptor
SYNOPSIS
#include <mtcp_api.h>
int mtcp_close(mctx_t mctx, int sockid);
DESCRIPTION
mtcp_close() closes the socket associated with sockid descriptor. This call can be used to gracefully terminate the underlying connection for active endpoint (SOCK_STREAM) sockets. All the underlying resources pertaining to the connection are also destroyed. mtcp_close() can also be used to shut down a passive listening socket. For monitoring socket types (MOS_SOCK_MONITOR_STREAM and MOS_SOCKET_MONITOR_RAW), all flow events are deregistered from the socket.
In all cases, the socket ID is made available for re-use for a future incoming connection request.
mtcp_close() call takes an additional argument named mctx that represents the per-core mTCP context in an application (see mtcp_create_context() for details).
RETURN VALUE
Returns 0 on success; -1 on failure and errno is set appropriately.
ERRORS
EACCES |
mctx is not valid. | ||
EAGAIN |
The request to close the connection was refused. | ||
EBADF |
sockid is not a valid socket descriptor for closing. | ||
EINVAL |
The socket specific to sockid has invalid type. | ||
ENOTCONN |
The connection referred to by sockid is already terminated. | ||
ENOTSOCK |
The socket referred to by sockid is not valid. |
NOTES
Please note that the same mctx context should be used to destroy the socket that created the socket via mtcp_socket () call in the first place. The user may experience unpredictable behavior if this practice is not followed.
AUTHORS
mOS development team <mtcp-user@list.ndsl.kaist.edu>
EXAMPLES
http://mos.kaist.edu/guide/programmer/05_api_example.html#application-destroy-routine
SEE ALSO
mtcp_socket()
COLOPHON
This page is part of mOS release 0.3 docs section. A description of the project, and information about reporting bugs, can be found at http://mos.kaist.edu/.