mtcp_connect

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.

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

EAFNOSUPPORT

The size of the addrlen argument passed is invalid.

EALREADY

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

EBADF

sockid is not a valid socket descriptor for creating a connection.

EFAULT

The addr argument passed is NULL.

EINVAL

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

EISCONN

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

ENOMEM

Connection failed due to insufficient memory.

ENOTSOCK

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

ETIMEDOUT

Connection failure due to TCP timeout.

AUTHORS

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

SEE ALSO

mtcp_bind(), mtcp_listen(), mtcp_accept(), mtcp_socket(), mtcp_read(), mtcp_write()

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/.