mtcp_getpeername 3 2017-08-28 "Linux" "mOS Library Functions Manual"
NAME
mtcp_getpeername - get name of end hosts being monitored by mOS
SYNOPSIS
#include <mos_api.h> "int mtcp_getpeername(mctx_t " mctx ", int " sockfd ", struct sockaddr *" addr ", socklen_t *" addrlen, int " side " );
DESCRIPTION
mtcp_getpeername () returns the address of the end hosts that is being monitored by the socket "sockfd" , in the buffer pointed to by "addr." The "addrlen" argument should be initialized to indicate the amount of space (in bytes) pointed to by "addr." On return it contains the actual size of the socket address. "side" variable should be properly set (either MOS_SIDE_CLI or MOS_SIDE_SVR) to specify on which side this function is interested in. If "addrlen" argument is set to have "2 * sizeof(struct sockaddr)" , it will fill up the socket address of the other side as well. An mtcp_getpeername () 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 zero on success; -1 on failure. In case of failure, "errno" is set appropriately. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
ERRORS

10 "EBADF" The argument "sockfd" is not a valid socket descriptor.

10 "EINVAL" "addrlen" argument is invalid (e.g., is negative).

10 "ENOTCONN" The argument "sockfd" is pointing to a mOS socket which has no corresponding stream that is being monitored. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""".SH CONFORMING TO
""""POSIX.1-2001.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

NOTES
The third argument of mtcp_getpeername() is in reality an "int *" (and this is what 4.x BSD and libc4 and libc5 have). Some POSIX confusion resulted in the present "socklen_t", also used by glibc. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
AUTHORS
mOS development team <[email protected]> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
SEE ALSO
mtcp_bind (), 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/. """""""""""""""""""""""""""""""""""""""""""""""""""""