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