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 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. In both 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

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

mTCP development team <mtcp-user@list.ndsl.kaist.edu>

SEE ALSO

mtcp_socket()

COLOPHON

This page is part of mTCP release 3.0 docs section. A description of the project, and information about reporting bugs, can be found at http://shader.kaist.edu/mtcp/.