1<!-- Creator     : groff version 1.22.2 -->
2<!-- CreationDate: Wed Feb  1 23:55:12 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
18</head>
19<body>
20
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
33<hr>
34
35
36<h2>NAME
37<a name="NAME"></a>
38</h2>
39
40
41
42<p style="margin-left:11%; margin-top: 1em">mtcp_getsockname
43&minus; get socket name</p>
44
45<h2>SYNOPSIS
46<a name="SYNOPSIS"></a>
47</h2>
48
49
50<p style="margin-left:11%; margin-top: 1em"><b>#include
51&lt;mtcp_api.h&gt;</b></p>
52
53<p style="margin-left:11%; margin-top: 1em"><b>int
54mtcp_getsockname(mctx_t</b> <i>mctx</i><b>, int</b>
55<i>sockfd</i><b>, struct sockaddr *</b><i>addr</i><b>,
56socklen_t *</b><i>addrlen</i><b>);</b></p>
57
58<h2>DESCRIPTION
59<a name="DESCRIPTION"></a>
60</h2>
61
62
63
64<p style="margin-left:11%; margin-top: 1em"><b>mtcp_getsockname</b>()
65returns the current address to which the socket
66<i>sockfd</i> is bound, in the buffer pointed to by
67<i>addr.</i> The <i>addrlen</i> argument should be
68initialized to indicate the amount of space (in bytes)
69pointed to by <i>addr.</i> On return it contains the actual
70size of the socket address.</p>
71
72<p style="margin-left:11%; margin-top: 1em">An
73<b>mtcp_getsockname</b>() call takes an additional argument
74named <i>mctx</i> that represents the per-core mTCP context
75in an application (see <b>mtcp_create_context()</b> for
76details).</p>
77
78<h2>RETURN VALUE
79<a name="RETURN VALUE"></a>
80</h2>
81
82
83<p style="margin-left:11%; margin-top: 1em">Returns zero on
84success; -1 on failure. In case of failure, <i>errno</i> is
85set appropriately.</p>
86
87<h2>ERRORS
88<a name="ERRORS"></a>
89</h2>
90
91
92<table width="100%" border="0" rules="none" frame="void"
93       cellspacing="0" cellpadding="0">
94<tr valign="top" align="left">
95<td width="11%"></td>
96<td width="12%">
97
98
99<p style="margin-top: 1em"><b>EBADF</b></p></td>
100<td width="3%"></td>
101<td width="74%">
102
103
104<p style="margin-top: 1em">The argument <i>sockfd</i> is
105not a valid socket descriptor.</p></td></tr>
106<tr valign="top" align="left">
107<td width="11%"></td>
108<td width="12%">
109
110
111<p><b>EINVAL</b></p></td>
112<td width="3%"></td>
113<td width="74%">
114
115
116<p><i>addrlen</i> argument is invalid (e.g., is
117negative).</p> </td></tr>
118<tr valign="top" align="left">
119<td width="11%"></td>
120<td width="12%">
121
122
123<p><b>ENOTSOCK</b></p></td>
124<td width="3%"></td>
125<td width="74%">
126
127
128<p>The argument <i>sockfd</i> is pointing to an invalid
129mTCP socket.</p></td></tr>
130</table>
131
132<h2>NOTES
133<a name="NOTES"></a>
134</h2>
135
136
137<p style="margin-left:11%; margin-top: 1em">The third
138argument of <b>mtcp_getsockname()</b> is in reality an
139<i>int *</i> (and this is what 4.x BSD and libc4 and libc5
140have). Some POSIX confusion resulted in the present
141<i>socklen_t ,</i> also used by glibc.</p>
142
143<h2>AUTHORS
144<a name="AUTHORS"></a>
145</h2>
146
147
148<p style="margin-left:11%; margin-top: 1em">mOS development
149team &lt;[email protected]&gt;</p>
150
151<h2>SEE ALSO
152<a name="SEE ALSO"></a>
153</h2>
154
155
156
157<p style="margin-left:11%; margin-top: 1em"><b>mtcp_bind</b>(),
158<b>mtcp_socket</b>()</p>
159
160<h2>COLOPHON
161<a name="COLOPHON"></a>
162</h2>
163
164
165<p style="margin-left:11%; margin-top: 1em">This page is
166part of mOS release 0.3 <i>docs</i> section. A description
167of the project, and information about reporting bugs, can be
168found at http://mos.kaist.edu/.</p>
169<hr>
170</body>
171</html>
172