.TH mtcp_getsockname 3 2017-02-01 "Linux" "mOS Library Functions Manual" .SH NAME mtcp_getsockname \- get socket name .SH SYNOPSIS .B #include .sp .BI "int mtcp_getsockname(mctx_t " mctx ", int " sockfd ", struct sockaddr *" addr ", socklen_t *" addrlen ); .SH DESCRIPTION .BR mtcp_getsockname () returns the current address to which the socket .I "sockfd" is bound, in the buffer pointed to by .I "addr." The .I "addrlen" argument should be initialized to indicate the amount of space (in bytes) pointed to by .I "addr." On return it contains the actual size of the socket address. An .BR mtcp_getsockname () call takes an additional argument named .I "mctx" that represents the per-core mTCP context in an application (see .BR mtcp_create_context() for details). .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .SH RETURN VALUE Returns zero on success; -1 on failure. In case of failure, .I "errno" is set appropriately. .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .SH ERRORS .TP 10 .B "EBADF" The argument .I "sockfd" is not a valid socket descriptor. .TP 10 .B "EINVAL" .I "addrlen" argument is invalid (e.g., is negative). .TP 10 .B "ENOTSOCK" The argument .I "sockfd" is pointing to an invalid mTCP socket. .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\""""".SH CONFORMING TO .\"""""POSIX.1-2001. .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .SH NOTES The third argument of .BR mtcp_getsockname() is in reality an .I "int *" (and this is what 4.x BSD and libc4 and libc5 have). Some POSIX confusion resulted in the present .I "socklen_t", also used by glibc. .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .SH AUTHORS mOS development team .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .SH SEE ALSO .BR mtcp_bind (), .BR mtcp_socket () .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" .SH COLOPHON This page is part of mOS release 0.3 .I "docs" section. A description of the project, and information about reporting bugs, can be found at \%http://mos.kaist.edu/. .\""""""""""""""""""""""""""""""""""""""""""""""""""""""