1e5df9dc1SAsim Jamshed<!-- Creator     : groff version 1.22.3 -->
2e5df9dc1SAsim Jamshed<!-- CreationDate: Mon Aug 28 02:48:48 2017 -->
3e5df9dc1SAsim Jamshed<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
4e5df9dc1SAsim Jamshed"http://www.w3.org/TR/html4/loose.dtd">
5e5df9dc1SAsim Jamshed<html>
6e5df9dc1SAsim Jamshed<head>
7e5df9dc1SAsim Jamshed<meta name="generator" content="groff -Thtml, see www.gnu.org">
8e5df9dc1SAsim Jamshed<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
9e5df9dc1SAsim Jamshed<meta name="Content-Style" content="text/css">
10e5df9dc1SAsim Jamshed<style type="text/css">
11e5df9dc1SAsim Jamshed       p       { margin-top: 0; margin-bottom: 0; vertical-align: top }
12e5df9dc1SAsim Jamshed       pre     { margin-top: 0; margin-bottom: 0; vertical-align: top }
13e5df9dc1SAsim Jamshed       table   { margin-top: 0; margin-bottom: 0; vertical-align: top }
14e5df9dc1SAsim Jamshed       h1      { text-align: center }
15e5df9dc1SAsim Jamshed</style>
16e5df9dc1SAsim Jamshed<title>mtcp_getpeername</title>
17e5df9dc1SAsim Jamshed<link rel="stylesheet" href="./common.css">
18e5df9dc1SAsim Jamshed</head>
19e5df9dc1SAsim Jamshed<body>
20e5df9dc1SAsim Jamshed<div class="main">
21e5df9dc1SAsim Jamshed<h1 align="center">mtcp_getpeername</h1>
22e5df9dc1SAsim Jamshed<!--
23e5df9dc1SAsim Jamshed<a href="#NAME">NAME</a><br>
24e5df9dc1SAsim Jamshed<a href="#SYNOPSIS">SYNOPSIS</a><br>
25e5df9dc1SAsim Jamshed<a href="#DESCRIPTION">DESCRIPTION</a><br>
26e5df9dc1SAsim Jamshed<a href="#RETURN VALUE">RETURN VALUE</a><br>
27e5df9dc1SAsim Jamshed<a href="#ERRORS">ERRORS</a><br>
28e5df9dc1SAsim Jamshed<a href="#NOTES">NOTES</a><br>
29e5df9dc1SAsim Jamshed<a href="#AUTHORS">AUTHORS</a><br>
30e5df9dc1SAsim Jamshed<a href="#SEE ALSO">SEE ALSO</a><br>
31e5df9dc1SAsim Jamshed<a href="#COLOPHON">COLOPHON</a><br>
32e5df9dc1SAsim Jamshed
33e5df9dc1SAsim Jamshed<hr>
34e5df9dc1SAsim Jamshed-->
35e5df9dc1SAsim Jamshed
36e5df9dc1SAsim Jamshed
37e5df9dc1SAsim Jamshed<h2>NAME
38e5df9dc1SAsim Jamshed<a name="NAME"></a>
39e5df9dc1SAsim Jamshed</h2>
40e5df9dc1SAsim Jamshed
41e5df9dc1SAsim Jamshed
42e5df9dc1SAsim Jamshed
43e5df9dc1SAsim Jamshed<p style="margin-left:11%; margin-top: 1em">mtcp_getpeername
44e5df9dc1SAsim Jamshed&minus; get name of end hosts being monitored by mOS</p>
45e5df9dc1SAsim Jamshed
46e5df9dc1SAsim Jamshed<h2>SYNOPSIS
47e5df9dc1SAsim Jamshed<a name="SYNOPSIS"></a>
48e5df9dc1SAsim Jamshed</h2>
49e5df9dc1SAsim Jamshed
50e5df9dc1SAsim Jamshed
51e5df9dc1SAsim Jamshed<p style="margin-left:11%; margin-top: 1em"><b>#include
52e5df9dc1SAsim Jamshed&lt;mos_api.h&gt;</b></p>
53e5df9dc1SAsim Jamshed
54e5df9dc1SAsim Jamshed<p style="margin-left:11%; margin-top: 1em"><b>int
55e5df9dc1SAsim Jamshedmtcp_getpeername(mctx_t</b> <i>mctx</i><b>, int</b>
56e5df9dc1SAsim Jamshed<i>sockfd</i><b>, struct sockaddr *</b><i>addr</i><b>,
57e5df9dc1SAsim Jamshedsocklen_t *</b><i>addrlen,</i><b>int</b> <i>side</i>
58e5df9dc1SAsim Jamshed<b>);</b></p>
59e5df9dc1SAsim Jamshed
60e5df9dc1SAsim Jamshed<h2>DESCRIPTION
61e5df9dc1SAsim Jamshed<a name="DESCRIPTION"></a>
62e5df9dc1SAsim Jamshed</h2>
63e5df9dc1SAsim Jamshed
64e5df9dc1SAsim Jamshed
65e5df9dc1SAsim Jamshed
66e5df9dc1SAsim Jamshed<p style="margin-left:11%; margin-top: 1em"><b>mtcp_getpeername</b>()
67e5df9dc1SAsim Jamshedreturns the address of the end hosts that is being monitored by the
68e5df9dc1SAsim Jamshedsocket <i>sockfd</i> , in the buffer pointed to by
69e5df9dc1SAsim Jamshed<i>addr.</i> The <i>addrlen</i> argument should be
70e5df9dc1SAsim Jamshedinitialized to indicate the amount of space (in bytes)
71e5df9dc1SAsim Jamshedpointed to by <i>addr.</i> On return it contains the actual
72e5df9dc1SAsim Jamshedsize of the socket address.</p>
73e5df9dc1SAsim Jamshed
74e5df9dc1SAsim Jamshed<p style="margin-left:11%; margin-top: 1em"><i>side</i>
75*626fc701SYoungGyoun  variable should be properly set to specify on which side
76*626fc701SYoungGyoun  this function is interested in.</p>
77e5df9dc1SAsim Jamshed
78*626fc701SYoungGyoun<p style="margin-left:11%; margin-top: 1em">If <i>side</i>
79*626fc701SYoungGyoun  argument is set to have <i>MOS_SIDE_CLI</i> or <i>MOS_SIDE_SVR</i>,
80*626fc701SYoungGyoun  <i>addrlen</i> should be <i>sizeof(struct sockaddr)</i>, and
81*626fc701SYoungGyoun  it will fill up the address buffer at <i>addr</i>
82*626fc701SYoungGyoun  with the address of the corresponding side.
83*626fc701SYoungGyoun
84*626fc701SYoungGyoun<p style="margin-left:11%; margin-top: 1em">
85*626fc701SYoungGyoun  If <i>side</i> argument is set to have <i>MOS_SIDE_BOTH</i>,
86*626fc701SYoungGyoun  <i>addrlen</i> should be <i>2 * sizeof(struct sockaddr)</i>
87*626fc701SYoungGyoun  , and it will fill up the address buffer at <i>addr</i>
88*626fc701SYoungGyoun  with the address of the corresponding side.
89*626fc701SYoungGyoun  The client-side address can be referred as <i>addr[MOS_SIDE_CLI]</i>,
90*626fc701SYoungGyoun  and the server-side can be referred as <i>addr[MOS_SIDE_SVR]</i>.
91e5df9dc1SAsim Jamshed</p>
92e5df9dc1SAsim Jamshed
93e5df9dc1SAsim Jamshed<p style="margin-left:11%; margin-top: 1em">An
94e5df9dc1SAsim Jamshed<b>mtcp_getpeername</b>() call takes an additional argument
95e5df9dc1SAsim Jamshednamed <i>mctx</i> that represents the per-core mTCP context
96e5df9dc1SAsim Jamshedin an application (see <b>mtcp_create_context()</b> for
97e5df9dc1SAsim Jamsheddetails).</p>
98e5df9dc1SAsim Jamshed
99e5df9dc1SAsim Jamshed<h2>RETURN VALUE
100e5df9dc1SAsim Jamshed<a name="RETURN VALUE"></a>
101e5df9dc1SAsim Jamshed</h2>
102e5df9dc1SAsim Jamshed
103e5df9dc1SAsim Jamshed
104e5df9dc1SAsim Jamshed<p style="margin-left:11%; margin-top: 1em">Returns zero on
105e5df9dc1SAsim Jamshedsuccess; -1 on failure. In case of failure, <i>errno</i> is
106e5df9dc1SAsim Jamshedset appropriately.</p>
107e5df9dc1SAsim Jamshed
108e5df9dc1SAsim Jamshed<h2>ERRORS
109e5df9dc1SAsim Jamshed<a name="ERRORS"></a>
110e5df9dc1SAsim Jamshed</h2>
111e5df9dc1SAsim Jamshed
112e5df9dc1SAsim Jamshed
113e5df9dc1SAsim Jamshed<table width="100%" border="0" rules="none" frame="void"
114e5df9dc1SAsim Jamshed       cellspacing="0" cellpadding="0">
115e5df9dc1SAsim Jamshed<tr valign="top" align="left">
116e5df9dc1SAsim Jamshed<td width="11%"></td>
117e5df9dc1SAsim Jamshed<td width="12%">
118e5df9dc1SAsim Jamshed
119e5df9dc1SAsim Jamshed
120e5df9dc1SAsim Jamshed<p style="margin-top: 1em"><b>EBADF</b></p></td>
121e5df9dc1SAsim Jamshed<td width="3%"></td>
122e5df9dc1SAsim Jamshed<td width="74%">
123e5df9dc1SAsim Jamshed
124e5df9dc1SAsim Jamshed
125e5df9dc1SAsim Jamshed<p style="margin-top: 1em">The argument <i>sockfd</i> is
126e5df9dc1SAsim Jamshednot a valid socket descriptor.</p></td></tr>
127e5df9dc1SAsim Jamshed<tr valign="top" align="left">
128e5df9dc1SAsim Jamshed<td width="11%"></td>
129e5df9dc1SAsim Jamshed<td width="12%">
130e5df9dc1SAsim Jamshed
131e5df9dc1SAsim Jamshed
132e5df9dc1SAsim Jamshed<p><b>EINVAL</b></p></td>
133e5df9dc1SAsim Jamshed<td width="3%"></td>
134e5df9dc1SAsim Jamshed<td width="74%">
135e5df9dc1SAsim Jamshed
136e5df9dc1SAsim Jamshed
137e5df9dc1SAsim Jamshed<p><i>addrlen</i> argument is invalid (e.g., is
138e5df9dc1SAsim Jamshednegative).</p> </td></tr>
139e5df9dc1SAsim Jamshed<tr valign="top" align="left">
140e5df9dc1SAsim Jamshed<td width="11%"></td>
141e5df9dc1SAsim Jamshed<td width="12%">
142e5df9dc1SAsim Jamshed
143e5df9dc1SAsim Jamshed
144e5df9dc1SAsim Jamshed<p><b>ENOTCONN</b></p></td>
145e5df9dc1SAsim Jamshed<td width="3%"></td>
146e5df9dc1SAsim Jamshed<td width="74%">
147e5df9dc1SAsim Jamshed
148e5df9dc1SAsim Jamshed
149e5df9dc1SAsim Jamshed<p>The argument <i>sockfd</i> is pointing to a mOS socket
150e5df9dc1SAsim Jamshedwhich has no corresponding stream that is being
151e5df9dc1SAsim Jamshedmonitored.</p> </td></tr>
152e5df9dc1SAsim Jamshed</table>
153e5df9dc1SAsim Jamshed
154e5df9dc1SAsim Jamshed<h2>NOTES
155e5df9dc1SAsim Jamshed<a name="NOTES"></a>
156e5df9dc1SAsim Jamshed</h2>
157e5df9dc1SAsim Jamshed
158e5df9dc1SAsim Jamshed
159e5df9dc1SAsim Jamshed<p style="margin-left:11%; margin-top: 1em">The third
160e5df9dc1SAsim Jamshedargument of <b>mtcp_getpeername()</b> is in reality an
161e5df9dc1SAsim Jamshed<i>int *</i> (and this is what 4.x BSD and libc4 and libc5
162e5df9dc1SAsim Jamshedhave). Some POSIX confusion resulted in the present
163e5df9dc1SAsim Jamshed<i>socklen_t ,</i> also used by glibc.</p>
164e5df9dc1SAsim Jamshed
165e5df9dc1SAsim Jamshed<h2>AUTHORS
166e5df9dc1SAsim Jamshed<a name="AUTHORS"></a>
167e5df9dc1SAsim Jamshed</h2>
168e5df9dc1SAsim Jamshed
169e5df9dc1SAsim Jamshed
170e5df9dc1SAsim Jamshed<p style="margin-left:11%; margin-top: 1em">mOS development
171e5df9dc1SAsim Jamshedteam &lt;[email protected]&gt;</p>
172e5df9dc1SAsim Jamshed
173*626fc701SYoungGyoun<!----------------------------------------------------------->
174*626fc701SYoungGyoun<h2>EXAMPLES
175*626fc701SYoungGyoun<a name="EXAMPLES"></a>
176*626fc701SYoungGyoun</h2>
177*626fc701SYoungGyoun
178*626fc701SYoungGyoun<p style="margin-left:11%; margin-top: 1em">
179*626fc701SYoungGyoun  <a href="http://mos.kaist.edu/guide/programmer/05_api_example.html#querying-end-point-host-address">
180*626fc701SYoungGyoun	http://mos.kaist.edu/guide/programmer/05_api_example.html#querying-end-point-host-address
181*626fc701SYoungGyoun	</a>
182*626fc701SYoungGyoun</p>
183*626fc701SYoungGyoun<!----------------------------------------------------------->
184*626fc701SYoungGyoun
185e5df9dc1SAsim Jamshed<h2>SEE ALSO
186e5df9dc1SAsim Jamshed<a name="SEE ALSO"></a>
187e5df9dc1SAsim Jamshed</h2>
188e5df9dc1SAsim Jamshed
189e5df9dc1SAsim Jamshed
190e5df9dc1SAsim Jamshed
191e5df9dc1SAsim Jamshed<p style="margin-left:11%; margin-top: 1em"><b>mtcp_bind</b>(),
192e5df9dc1SAsim Jamshed<b>mtcp_socket</b>()</p>
193e5df9dc1SAsim Jamshed
194e5df9dc1SAsim Jamshed<h2>COLOPHON
195e5df9dc1SAsim Jamshed<a name="COLOPHON"></a>
196e5df9dc1SAsim Jamshed</h2>
197e5df9dc1SAsim Jamshed
198e5df9dc1SAsim Jamshed
199e5df9dc1SAsim Jamshed<p style="margin-left:11%; margin-top: 1em">This page is
200e5df9dc1SAsim Jamshedpart of mOS release 0.3 <i>docs</i> section. A description
201e5df9dc1SAsim Jamshedof the project, and information about reporting bugs, can be
202e5df9dc1SAsim Jamshedfound at http://mos.kaist.edu/.</p>
203e5df9dc1SAsim Jamshed<hr>
204e5df9dc1SAsim Jamshed<div class="footer">
205e5df9dc1SAsim Jamshed  <img src="back-arrow.jpg" width="2%" height="2%"><a href="http://mos.kaist.edu/index_man.html">Back to Index</a>
206e5df9dc1SAsim Jamshed</div>
207e5df9dc1SAsim Jamshed</div>
208e5df9dc1SAsim Jamshed</body>
209e5df9dc1SAsim Jamshed</html>
210