xref: /mOS-networking-stack/docs/man/mtcp_bind (revision dcdbbb98)
mtcp_bind 3 2017-02-01 "Linux" "mOS Library Functions Manual"
NAME
mtcp_bind - bind an IP address to an mTCP socket
SYNOPSIS
#include <mtcp_api.h> "int mtcp_bind(mctx_t " mctx ", int " sockid ", const struct sockaddr *" addr ", socklen_t " addrlen );
DESCRIPTION
mtcp_bind () can be used to bind an IPv4 address (assigning a name) to an mTCP socket. This socket is referred to by the "sockid" argument. The "addr" structure contains the address and the port number (both in network byte order) to be bound while the "addrlen" specifies the size of the address structure pointing to "addr." The actual structure passed for the "addr" argument is defined as:

struct sockaddr {
 sa_family_t sa_family; /* AF_INET */
 char sa_data[14]; /* IPv4 address + TCP port */
}

It is necessary to assign a local address using mtcp_bind() on a passive socket before it can be used to receive connections using mtcp_accept(). The mtcp_bind () 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. In case of failure, "errno" is set appropriately. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
ERRORS

10 "EBADF" "sockid" is not a valid socket descriptor for binding to an address.

10 "EINVAL" The "addr" argument is NULL. This may also mean that an address is already bound to the current "sockid" descriptor.

10 "ENOTSOCK" The socket referred to by "sockid" has an invalid type. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""".SH CONFORMING TO
""""POSIX.1-2001.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

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