1<!-- Creator : groff version 1.22.3 --> 2<!-- CreationDate: Mon Aug 28 02:48:48 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_getpeername</title> 17<link rel="stylesheet" href="./common.css"> 18</head> 19<body> 20<div class="main"> 21<h1 align="center">mtcp_getpeername</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 33<hr> 34--> 35 36 37<h2>NAME 38<a name="NAME"></a> 39</h2> 40 41 42 43<p style="margin-left:11%; margin-top: 1em">mtcp_getpeername 44− get name of end hosts being monitored by mOS</p> 45 46<h2>SYNOPSIS 47<a name="SYNOPSIS"></a> 48</h2> 49 50 51<p style="margin-left:11%; margin-top: 1em"><b>#include 52<mos_api.h></b></p> 53 54<p style="margin-left:11%; margin-top: 1em"><b>int 55mtcp_getpeername(mctx_t</b> <i>mctx</i><b>, int</b> 56<i>sockfd</i><b>, struct sockaddr *</b><i>addr</i><b>, 57socklen_t *</b><i>addrlen,</i><b>int</b> <i>side</i> 58<b>);</b></p> 59 60<h2>DESCRIPTION 61<a name="DESCRIPTION"></a> 62</h2> 63 64 65 66<p style="margin-left:11%; margin-top: 1em"><b>mtcp_getpeername</b>() 67returns the address of the end hosts that is being monitored by the 68socket <i>sockfd</i> , in the buffer pointed to by 69<i>addr.</i> The <i>addrlen</i> argument should be 70initialized to indicate the amount of space (in bytes) 71pointed to by <i>addr.</i> On return it contains the actual 72size of the socket address.</p> 73 74<p style="margin-left:11%; margin-top: 1em"><i>side</i> 75variable should be properly set (either MOS_SIDE_CLI or 76MOS_SIDE_SVR) to specify on which side this function is 77 interested in.</p> 78 79<p style="margin-left:11%; margin-top: 1em">If <i>addrlen</i> 80argument is set to be <i>2 * sizeof(struct sockaddr)</i>, 81it will fill up the socket address of the other side as well. 82</p> 83 84<p style="margin-left:11%; margin-top: 1em">An 85<b>mtcp_getpeername</b>() call takes an additional argument 86named <i>mctx</i> that represents the per-core mTCP context 87in an application (see <b>mtcp_create_context()</b> for 88details).</p> 89 90<h2>RETURN VALUE 91<a name="RETURN VALUE"></a> 92</h2> 93 94 95<p style="margin-left:11%; margin-top: 1em">Returns zero on 96success; -1 on failure. In case of failure, <i>errno</i> is 97set appropriately.</p> 98 99<h2>ERRORS 100<a name="ERRORS"></a> 101</h2> 102 103 104<table width="100%" border="0" rules="none" frame="void" 105 cellspacing="0" cellpadding="0"> 106<tr valign="top" align="left"> 107<td width="11%"></td> 108<td width="12%"> 109 110 111<p style="margin-top: 1em"><b>EBADF</b></p></td> 112<td width="3%"></td> 113<td width="74%"> 114 115 116<p style="margin-top: 1em">The argument <i>sockfd</i> is 117not a valid socket descriptor.</p></td></tr> 118<tr valign="top" align="left"> 119<td width="11%"></td> 120<td width="12%"> 121 122 123<p><b>EINVAL</b></p></td> 124<td width="3%"></td> 125<td width="74%"> 126 127 128<p><i>addrlen</i> argument is invalid (e.g., is 129negative).</p> </td></tr> 130<tr valign="top" align="left"> 131<td width="11%"></td> 132<td width="12%"> 133 134 135<p><b>ENOTCONN</b></p></td> 136<td width="3%"></td> 137<td width="74%"> 138 139 140<p>The argument <i>sockfd</i> is pointing to a mOS socket 141which has no corresponding stream that is being 142monitored.</p> </td></tr> 143</table> 144 145<h2>NOTES 146<a name="NOTES"></a> 147</h2> 148 149 150<p style="margin-left:11%; margin-top: 1em">The third 151argument of <b>mtcp_getpeername()</b> is in reality an 152<i>int *</i> (and this is what 4.x BSD and libc4 and libc5 153have). Some POSIX confusion resulted in the present 154<i>socklen_t ,</i> also used by glibc.</p> 155 156<h2>AUTHORS 157<a name="AUTHORS"></a> 158</h2> 159 160 161<p style="margin-left:11%; margin-top: 1em">mOS development 162team <[email protected]></p> 163 164<h2>SEE ALSO 165<a name="SEE ALSO"></a> 166</h2> 167 168 169 170<p style="margin-left:11%; margin-top: 1em"><b>mtcp_bind</b>(), 171<b>mtcp_socket</b>()</p> 172 173<h2>COLOPHON 174<a name="COLOPHON"></a> 175</h2> 176 177 178<p style="margin-left:11%; margin-top: 1em">This page is 179part of mOS release 0.3 <i>docs</i> section. A description 180of the project, and information about reporting bugs, can be 181found at http://mos.kaist.edu/.</p> 182<hr> 183<div class="footer"> 184 <img src="back-arrow.jpg" width="2%" height="2%"><a href="http://mos.kaist.edu/index_man.html">Back to Index</a> 185</div> 186</div> 187</body> 188</html> 189