1<!-- Creator : groff version 1.22.2 --> 2<!-- CreationDate: Thu Feb 2 01:55:58 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_close</title> 17 18</head> 19<body> 20 21<h1 align="center">mtcp_close</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<p style="margin-left:11%; margin-top: 1em">mtcp_close 42− close an mTCP socket descriptor</p> 43 44<h2>SYNOPSIS 45<a name="SYNOPSIS"></a> 46</h2> 47 48 49<p style="margin-left:11%; margin-top: 1em"><b>#include 50<mtcp_api.h></b></p> 51 52<p style="margin-left:11%; margin-top: 1em"><b>int 53mtcp_close(mctx_t</b> <i>mctx</i><b>, int</b> 54<i>sockid</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_close</b>() 63closes the socket associated with <i>sockid</i> descriptor. 64This call can be used to gracefully terminate the underlying 65connection for active endpoint (SOCK_STREAM) sockets. All 66the underlying resources pertaining to the connection are 67also destroyed. <b>mtcp_close()</b> can also be used to shut 68down a passive listening socket. For monitoring socket types 69(MOS_SOCK_MONITOR_STREAM and MOS_SOCKET_MONITOR_RAW), all 70flow events are deregistered from the socket.</p> 71 72<p style="margin-left:11%; margin-top: 1em">In all cases, 73the socket ID is made available for re-use for a future 74incoming connection request.</p> 75 76 77<p style="margin-left:11%; margin-top: 1em"><b>mtcp_close</b>() 78call takes an additional argument named <i>mctx</i> that 79represents the per-core mTCP context in an application (see 80<b>mtcp_create_context()</b> 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 and <i>errno</i> is set 89appropriately.</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="12%"> 101 102 103<p style="margin-top: 1em"><b>EACCES</b></p></td> 104<td width="3%"></td> 105<td width="74%"> 106 107 108<p style="margin-top: 1em"><i>mctx</i> is not valid.</p></td></tr> 109<tr valign="top" align="left"> 110<td width="11%"></td> 111<td width="12%"> 112 113 114<p><b>EAGAIN</b></p></td> 115<td width="3%"></td> 116<td width="74%"> 117 118 119<p>The request to close the connection was refused.</p></td></tr> 120<tr valign="top" align="left"> 121<td width="11%"></td> 122<td width="12%"> 123 124 125<p><b>EBADF</b></p></td> 126<td width="3%"></td> 127<td width="74%"> 128 129 130<p><i>sockid</i> is not a valid socket descriptor for 131closing.</p> </td></tr> 132<tr valign="top" align="left"> 133<td width="11%"></td> 134<td width="12%"> 135 136 137<p><b>EINVAL</b></p></td> 138<td width="3%"></td> 139<td width="74%"> 140 141 142<p>The socket specific to <i>sockid</i> has invalid 143type.</p> </td></tr> 144<tr valign="top" align="left"> 145<td width="11%"></td> 146<td width="12%"> 147 148 149<p><b>ENOTCONN</b></p></td> 150<td width="3%"></td> 151<td width="74%"> 152 153 154<p>The connection referred to by <i>sockid</i> is already 155terminated.</p> </td></tr> 156<tr valign="top" align="left"> 157<td width="11%"></td> 158<td width="12%"> 159 160 161<p><b>ENOTSOCK</b></p></td> 162<td width="3%"></td> 163<td width="74%"> 164 165 166<p>The socket referred to by <i>sockid</i> is not 167valid.</p> </td></tr> 168</table> 169 170<h2>NOTES 171<a name="NOTES"></a> 172</h2> 173 174 175<p style="margin-left:11%; margin-top: 1em">Please note 176that the same <i>mctx</i> context should be used to destroy 177the socket that created the socket via <b>mtcp_socket ()</b> 178call in the first place. The user may experience 179unpredictable behavior if this practice is not followed.</p> 180 181<h2>AUTHORS 182<a name="AUTHORS"></a> 183</h2> 184 185 186<p style="margin-left:11%; margin-top: 1em">mOS development 187team <[email protected]></p> 188 189<h2>SEE ALSO 190<a name="SEE ALSO"></a> 191</h2> 192 193 194 195<p style="margin-left:11%; margin-top: 1em"><b>mtcp_socket</b>()</p> 196 197<h2>COLOPHON 198<a name="COLOPHON"></a> 199</h2> 200 201 202<p style="margin-left:11%; margin-top: 1em">This page is 203part of mOS release 0.3 <i>docs</i> section. A description 204of the project, and information about reporting bugs, can be 205found at http://mos.kaist.edu/.</p> 206<hr> 207</body> 208</html> 209