xref: /mOS-networking-stack/docs/man/mtcp_close (revision dcdbbb98)
mtcp_close 3 2017-02-01 "Linux" "mOS Library Functions Manual"
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. """""after a mandatory
""""".BR "TCP_TIMEOUT"
"""""threshold period passes.
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

10 "EACCES" "mctx" is not valid.

10 "EAGAIN" The request to close the connection was refused.

10 "EBADF" "sockid" is not a valid socket descriptor for closing.

10 "EINVAL" The socket specific to "sockid" has invalid type.

10 "ENOTCONN" The connection referred to by "sockid" is already terminated.

10 "ENOTSOCK" The socket referred to by "sockid" is not valid. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""".SH CONFORMING TO
""""POSIX.1-2001.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

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 <[email protected]> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
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/. """""""""""""""""""""""""""""""""""""""""""""""""""""