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<link rel="stylesheet" href="./common.css"> 18</head> 19<body> 20<div class="main"> 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<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_close 41− close an mTCP socket descriptor</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<mtcp_api.h></b></p> 50 51<p style="margin-left:11%; margin-top: 1em"><b>int 52mtcp_close(mctx_t</b> <i>mctx</i><b>, int</b> 53<i>sockid</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_close</b>() 62closes the socket associated with <i>sockid</i> descriptor. 63This call can be used to gracefully terminate the underlying 64connection for active endpoint (SOCK_STREAM) sockets. All 65the underlying resources pertaining to the connection are 66also destroyed. <b>mtcp_close()</b> can also be used to shut 67down a passive listening socket. For monitoring socket types 68(MOS_SOCK_MONITOR_STREAM and MOS_SOCKET_MONITOR_RAW), all 69flow events are deregistered from the socket.</p> 70 71<p style="margin-left:11%; margin-top: 1em">In all cases, 72the socket ID is made available for re-use for a future 73incoming connection request.</p> 74 75 76<p style="margin-left:11%; margin-top: 1em"><b>mtcp_close</b>() 77call takes an additional argument named <i>mctx</i> that 78represents the per-core mTCP context in an application (see 79<b>mtcp_create_context()</b> for details).</p> 80 81<h2>RETURN VALUE 82<a name="RETURN VALUE"></a> 83</h2> 84 85 86<p style="margin-left:11%; margin-top: 1em">Returns 0 on 87success; -1 on failure and <i>errno</i> is set 88appropriately.</p> 89 90<h2>ERRORS 91<a name="ERRORS"></a> 92</h2> 93 94 95<table width="100%" border="0" rules="none" frame="void" 96 cellspacing="0" cellpadding="0"> 97<tr valign="top" align="left"> 98<td width="11%"></td> 99<td width="12%"> 100 101 102<p style="margin-top: 1em"><b>EACCES</b></p></td> 103<td width="3%"></td> 104<td width="74%"> 105 106 107<p style="margin-top: 1em"><i>mctx</i> is not valid.</p></td></tr> 108<tr valign="top" align="left"> 109<td width="11%"></td> 110<td width="12%"> 111 112 113<p><b>EAGAIN</b></p></td> 114<td width="3%"></td> 115<td width="74%"> 116 117 118<p>The request to close the connection was refused.</p></td></tr> 119<tr valign="top" align="left"> 120<td width="11%"></td> 121<td width="12%"> 122 123 124<p><b>EBADF</b></p></td> 125<td width="3%"></td> 126<td width="74%"> 127 128 129<p><i>sockid</i> is not a valid socket descriptor for 130closing.</p> </td></tr> 131<tr valign="top" align="left"> 132<td width="11%"></td> 133<td width="12%"> 134 135 136<p><b>EINVAL</b></p></td> 137<td width="3%"></td> 138<td width="74%"> 139 140 141<p>The socket specific to <i>sockid</i> has invalid 142type.</p> </td></tr> 143<tr valign="top" align="left"> 144<td width="11%"></td> 145<td width="12%"> 146 147 148<p><b>ENOTCONN</b></p></td> 149<td width="3%"></td> 150<td width="74%"> 151 152 153<p>The connection referred to by <i>sockid</i> is already 154terminated.</p> </td></tr> 155<tr valign="top" align="left"> 156<td width="11%"></td> 157<td width="12%"> 158 159 160<p><b>ENOTSOCK</b></p></td> 161<td width="3%"></td> 162<td width="74%"> 163 164 165<p>The socket referred to by <i>sockid</i> is not 166valid.</p> </td></tr> 167</table> 168 169<h2>NOTES 170<a name="NOTES"></a> 171</h2> 172 173 174<p style="margin-left:11%; margin-top: 1em">Please note 175that the same <i>mctx</i> context should be used to destroy 176the socket that created the socket via <b>mtcp_socket ()</b> 177call in the first place. The user may experience 178unpredictable behavior if this practice is not followed.</p> 179 180<h2>AUTHORS 181<a name="AUTHORS"></a> 182</h2> 183 184 185<p style="margin-left:11%; margin-top: 1em">mOS development 186team <[email protected]></p> 187 188<!-----------------------------------------------------------> 189<h2>EXAMPLES 190<a name="EXAMPLES"></a> 191</h2> 192 193<p style="margin-left:11%; margin-top: 1em"> 194 <a href="http://mos.kaist.edu/guide/programmer/05_api_example.html#application-destroy-routine"> 195 http://mos.kaist.edu/guide/programmer/05_api_example.html#application-destroy-routine 196 </a> 197</p> 198<!-----------------------------------------------------------> 199 200<h2>SEE ALSO 201<a name="SEE ALSO"></a> 202</h2> 203 204 205 206<p style="margin-left:11%; margin-top: 1em"><b>mtcp_socket</b>()</p> 207 208<h2>COLOPHON 209<a name="COLOPHON"></a> 210</h2> 211 212 213<p style="margin-left:11%; margin-top: 1em">This page is 214part of mOS release 0.3 <i>docs</i> section. A description 215of the project, and information about reporting bugs, can be 216found at http://mos.kaist.edu/.</p> 217<!--<hr>--> 218<br> 219<div class="footer"> 220 <img src="back-arrow.jpg" width="2%" height="2%"><a href="http://mos.kaist.edu/index_man.html">Back to Index</a> 221</div> 222</div> 223</body> 224</html> 225