mtcp_connect 3 2017-02-01 "Linux" "mOS Library Functions Manual"
NAME
mtcp_connect - create a connection on an mTCP socket
SYNOPSIS
#include <mtcp_api.h> "int mtcp_connect(mctx_t " mctx ", int " sockid ", const struct sockaddr *" addr ", socklen_t " addrlen );
DESCRIPTION
mtcp_connect () connects the socket referred via "sockid" argument to the TCP peer whose address and port number are filled by the user in "addr" structure in network byte order. The "addrlen" argument specifies the size of the "addr" address in bytes. The user is responsible for allocating memory for "addr" and "addrlen" arguments. A successful invocation of "mtcp_connect()" call yields in a connection of the socket to its peer endpoint. """in
""".BR "ESTABLISHED"
"""TCP state.
An mtcp_connect () call takes an additional argument named "mctx" that represents the per-core mTCP context in an application (see mtcp_create_context() for details). The user is expected to use a specific <srcipaddr, srctcpport, destipaddr, desttcpport> tuple which ensures that bidirectional traffic of the connection is handled by the same "mctx" context. See "mtcp_init_rss()" man page for details. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
RETURN VALUE
Returns 0 on success; -1 on failure. In case of failure, "errno" is set appropriately. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
ERRORS

15 "EAFNOSUPPORT" The size of the "addrlen" argument passed is invalid.

15 "EALREADY" The socket referred to by "sockid" descriptor is already connected (with a TCP state < "ESTABLISHED") to a peer endpoint.

15 "EBADF" "sockid" is not a valid socket descriptor for creating a connection.

15 "EFAULT" The "addr" argument passed is NULL.

15 "EINVAL" Connection request for the given "addr" is invalid (due to incorrect <addr,port>-to-NIC_queue binding).

15 "EISCONN" The socket referred to by "sockid" descriptor already has an established connection with a peer endpoint.

15 "ENOMEM" Connection failed due to insufficient memory.

15 "ENOTSOCK" The socket referred to by "sockid" does not have a valid socket type.

15 "ETIMEDOUT" Connection failure due to TCP timeout. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""".SH CONFORMING TO
""""POSIX.1-2001.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

AUTHORS
mOS development team <[email protected]> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
SEE ALSO
mtcp_bind (), mtcp_listen (), mtcp_accept (), mtcp_socket (), mtcp_read (), mtcp_write () """""""""""""""""""""""""""""""""""""""""""""""""""""
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/. """""""""""""""""""""""""""""""""""""""""""""""""""""