1<!-- Creator : groff version 1.22.2 --> 2<!-- CreationDate: Wed Feb 1 22:24:31 2017 --> 3<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 4"http://www.w3.org/TR/html4/loose.dtd"> 5<html> 6<head> 7<meta name="generator" content="groff -Thtml, see www.gnu.org"> 8<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> 9<meta name="Content-Style" content="text/css"> 10<style type="text/css"> 11 p { margin-top: 0; margin-bottom: 0; vertical-align: top } 12 pre { margin-top: 0; margin-bottom: 0; vertical-align: top } 13 table { margin-top: 0; margin-bottom: 0; vertical-align: top } 14 h1 { text-align: center } 15</style> 16<title>mtcp_getsockname</title> 17<link rel="stylesheet" href="./common.css"> 18</head> 19<body> 20<div class="main"> 21<h1 align="center">mtcp_getsockname</h1> 22<!-- 23<a href="#NAME">NAME</a><br> 24<a href="#SYNOPSIS">SYNOPSIS</a><br> 25<a href="#DESCRIPTION">DESCRIPTION</a><br> 26<a href="#RETURN VALUE">RETURN VALUE</a><br> 27<a href="#ERRORS">ERRORS</a><br> 28<a href="#NOTES">NOTES</a><br> 29<a href="#AUTHORS">AUTHORS</a><br> 30<a href="#SEE ALSO">SEE ALSO</a><br> 31<a href="#COLOPHON">COLOPHON</a><br> 32<hr> 33--> 34 35<h2>NAME 36<a name="NAME"></a> 37</h2> 38 39 40 41<p style="margin-left:11%; margin-top: 1em">mtcp_getsockname 42− get socket name</p> 43 44<h2>SYNOPSIS 45<a name="SYNOPSIS"></a> 46</h2> 47 48 49<p style="margin-left:11%; margin-top: 1em"><b>#include 50<mtcp_api.h></b></p> 51 52<p style="margin-left:11%; margin-top: 1em"><b>int 53mtcp_getsockname(mctx_t</b> <i>mctx</i><b>, int</b> 54<i>sockfd</i><b>, struct sockaddr *</b><i>addr</i><b>, 55socklen_t *</b><i>addrlen</i><b>);</b></p> 56 57<h2>DESCRIPTION 58<a name="DESCRIPTION"></a> 59</h2> 60 61 62 63<p style="margin-left:11%; margin-top: 1em"><b>mtcp_getsockname</b>() 64returns the current address to which the socket 65<i>sockfd</i> is bound, in the buffer pointed to by 66<i>addr.</i> The <i>addrlen</i> argument should be 67initialized to indicate the amount of space (in bytes) 68pointed to by <i>addr.</i> On return it contains the actual 69size of the socket address.</p> 70 71<p style="margin-left:11%; margin-top: 1em">An 72<b>mtcp_getsockname</b>() call takes an additional argument 73named <i>mctx</i> that represents the per-core mTCP context 74in an application (see <b>mtcp_create_context()</b> for 75details).</p> 76 77<h2>RETURN VALUE 78<a name="RETURN VALUE"></a> 79</h2> 80 81 82<p style="margin-left:11%; margin-top: 1em">Returns zero on 83success; -1 on failure. In case of failure, <i>errno</i> is 84set appropriately.</p> 85 86<h2>ERRORS 87<a name="ERRORS"></a> 88</h2> 89 90 91<table width="100%" border="0" rules="none" frame="void" 92 cellspacing="0" cellpadding="0"> 93<tr valign="top" align="left"> 94<td width="11%"></td> 95<td width="12%"> 96 97 98<p style="margin-top: 1em"><b>EBADF</b></p></td> 99<td width="3%"></td> 100<td width="74%"> 101 102 103<p style="margin-top: 1em">The argument <i>sockfd</i> is 104not a valid socket descriptor.</p></td></tr> 105<tr valign="top" align="left"> 106<td width="11%"></td> 107<td width="12%"> 108 109 110<p><b>EINVAL</b></p></td> 111<td width="3%"></td> 112<td width="74%"> 113 114 115<p><i>addrlen</i> argument is invalid (e.g., is 116negative).</p> </td></tr> 117<tr valign="top" align="left"> 118<td width="11%"></td> 119<td width="12%"> 120 121 122<p><b>ENOTSOCK</b></p></td> 123<td width="3%"></td> 124<td width="74%"> 125 126 127<p>The argument <i>sockfd</i> is pointing to an invalid 128mTCP socket.</p></td></tr> 129</table> 130 131<h2>NOTES 132<a name="NOTES"></a> 133</h2> 134 135 136<p style="margin-left:11%; margin-top: 1em">The third 137argument of <b>mtcp_getsockname()</b> is in reality an 138<i>int *</i> (and this is what 4.x BSD and libc4 and libc5 139have). Some POSIX confusion resulted in the present 140<i>socklen_t ,</i> also used by glibc.</p> 141 142<h2>AUTHORS 143<a name="AUTHORS"></a> 144</h2> 145 146 147<p style="margin-left:11%; margin-top: 1em">mOS 148development team <[email protected]></p> 149 150<h2>SEE ALSO 151<a name="SEE ALSO"></a> 152</h2> 153 154 155 156<p style="margin-left:11%; margin-top: 1em"><b>mtcp_bind</b>(), 157<b>mtcp_socket</b>()</p> 158 159<h2>COLOPHON 160<a name="COLOPHON"></a> 161</h2> 162 163 164<p style="margin-left:11%; margin-top: 1em">This page is 165part of mOS release 0.3 <i>docs</i> section. A description 166of the project, and information about reporting bugs, can be 167found at http://mos.kaist.edu/.</p> 168<!-- <hr> --> 169<br> 170<div class="footer"> 171 <img src="back-arrow.jpg" width="2%" height="2%"><a href="http://mos.kaist.edu/index_man.html">Back to Index</a> 172</div> 173</div> 174</body> 175</html> 176