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_connect</title>
17
18</head>
19<body>
20
21<h1 align="center">mtcp_connect</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="#AUTHORS">AUTHORS</a><br>
29<a href="#SEE ALSO">SEE ALSO</a><br>
30<a href="#COLOPHON">COLOPHON</a><br>
31
32<hr>
33
34
35<h2>NAME
36<a name="NAME"></a>
37</h2>
38
39
40<p style="margin-left:11%; margin-top: 1em">mtcp_connect
41&minus; create a connection on an mTCP socket</p>
42
43<h2>SYNOPSIS
44<a name="SYNOPSIS"></a>
45</h2>
46
47
48<p style="margin-left:11%; margin-top: 1em"><b>#include
49&lt;mtcp_api.h&gt;</b></p>
50
51<p style="margin-left:11%; margin-top: 1em"><b>int
52mtcp_connect(mctx_t</b> <i>mctx</i><b>, int</b>
53<i>sockid</i><b>, const struct sockaddr *</b><i>addr</i><b>,
54socklen_t</b> <i>addrlen</i><b>);</b></p>
55
56<h2>DESCRIPTION
57<a name="DESCRIPTION"></a>
58</h2>
59
60
61
62<p style="margin-left:11%; margin-top: 1em"><b>mtcp_connect</b>()
63connects the socket referred via <i>sockid</i> argument to
64the TCP peer whose address and port number are filled by the
65user in <i>addr</i> structure in network byte order. The
66<i>addrlen</i> argument specifies the size of the
67<i>addr</i> address in bytes. The user is responsible for
68allocating memory for <i>addr</i> and <i>addrlen</i>
69arguments. A successful invocation of <b>mtcp_connect()</b>
70call yields in a connection of the socket to its peer
71endpoint.</p>
72
73<p style="margin-left:11%; margin-top: 1em">An
74<b>mtcp_connect</b>() call takes an additional argument
75named <i>mctx</i> that represents the per-core mTCP context
76in an application (see <b>mtcp_create_context()</b> for
77details). The user is expected to use a specific
78&lt;srcipaddr, srctcpport, destipaddr, desttcpport&gt; tuple
79which ensures that bidirectional traffic of the connection
80is handled by the same <i>mctx</i> context. See
81<b>mtcp_init_rss()</b> man page for details.</p>
82
83<h2>RETURN VALUE
84<a name="RETURN VALUE"></a>
85</h2>
86
87
88<p style="margin-left:11%; margin-top: 1em">Returns 0 on
89success; -1 on failure. In case of failure, <i>errno</i> is
90set appropriately.</p>
91
92<h2>ERRORS
93<a name="ERRORS"></a>
94</h2>
95
96
97<table width="100%" border="0" rules="none" frame="void"
98       cellspacing="0" cellpadding="0">
99<tr valign="top" align="left">
100<td width="11%"></td>
101<td width="18%">
102
103
104<p style="margin-top: 1em"><b>EAFNOSUPPORT</b></p></td>
105<td width="5%"></td>
106<td width="66%">
107
108
109<p style="margin-top: 1em">The size of the <i>addrlen</i>
110argument passed is invalid.</p></td></tr>
111<tr valign="top" align="left">
112<td width="11%"></td>
113<td width="18%">
114
115
116<p><b>EALREADY</b></p></td>
117<td width="5%"></td>
118<td width="66%">
119
120
121<p>The socket referred to by <i>sockid</i> descriptor is
122already connected (with a TCP state &lt; <b>ESTABLISHED</b>)
123to a peer endpoint.</p></td></tr>
124<tr valign="top" align="left">
125<td width="11%"></td>
126<td width="18%">
127
128
129<p><b>EBADF</b></p></td>
130<td width="5%"></td>
131<td width="66%">
132
133
134<p><i>sockid</i> is not a valid socket descriptor for
135creating a connection.</p></td></tr>
136<tr valign="top" align="left">
137<td width="11%"></td>
138<td width="18%">
139
140
141<p><b>EFAULT</b></p></td>
142<td width="5%"></td>
143<td width="66%">
144
145
146<p>The <i>addr</i> argument passed is NULL.</p></td></tr>
147<tr valign="top" align="left">
148<td width="11%"></td>
149<td width="18%">
150
151
152<p><b>EINVAL</b></p></td>
153<td width="5%"></td>
154<td width="66%">
155
156
157<p>Connection request for the given <i>addr</i> is invalid
158(due to incorrect &lt;addr,port&gt;-to-NIC_queue
159binding).</p> </td></tr>
160<tr valign="top" align="left">
161<td width="11%"></td>
162<td width="18%">
163
164
165<p><b>EISCONN</b></p></td>
166<td width="5%"></td>
167<td width="66%">
168
169
170<p>The socket referred to by <i>sockid</i> descriptor
171already has an established connection with a peer
172endpoint.</p> </td></tr>
173<tr valign="top" align="left">
174<td width="11%"></td>
175<td width="18%">
176
177
178<p><b>ENOMEM</b></p></td>
179<td width="5%"></td>
180<td width="66%">
181
182
183<p>Connection failed due to insufficient memory.</p></td></tr>
184<tr valign="top" align="left">
185<td width="11%"></td>
186<td width="18%">
187
188
189<p><b>ENOTSOCK</b></p></td>
190<td width="5%"></td>
191<td width="66%">
192
193
194<p>The socket referred to by <i>sockid</i> does not have a
195valid socket type.</p></td></tr>
196<tr valign="top" align="left">
197<td width="11%"></td>
198<td width="18%">
199
200
201<p><b>ETIMEDOUT</b></p></td>
202<td width="5%"></td>
203<td width="66%">
204
205
206<p>Connection failure due to TCP timeout.</p></td></tr>
207</table>
208
209<h2>AUTHORS
210<a name="AUTHORS"></a>
211</h2>
212
213
214<p style="margin-left:11%; margin-top: 1em">mOS development
215team &lt;[email protected]&gt;</p>
216
217<h2>SEE ALSO
218<a name="SEE ALSO"></a>
219</h2>
220
221
222
223<p style="margin-left:11%; margin-top: 1em"><b>mtcp_bind</b>(),
224<b>mtcp_listen</b>(), <b>mtcp_accept</b>(),
225<b>mtcp_socket</b>(), <b>mtcp_read</b>(),
226<b>mtcp_write</b>()</p>
227
228<h2>COLOPHON
229<a name="COLOPHON"></a>
230</h2>
231
232
233<p style="margin-left:11%; margin-top: 1em">This page is
234part of mOS release 0.3 <i>docs</i> section. A description
235of the project, and information about reporting bugs, can be
236found at http://mos.kaist.edu/.</p>
237<hr>
238</body>
239</html>
240