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_read</title> 17<link rel="stylesheet" href="./common.css"> 18</head> 19<body> 20<div class="main"> 21<h1 align="center">mtcp_read</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_read 40− read bytestream from 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>ssize_t 51mtcp_read(mctx_t</b> <i>mctx</i><b>, int</b> 52<i>sockid</i><b>, char *</b><i>buf</i><b>, size_t</b> 53<i>len</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_read</b>() 62can be used to read up to <i>len</i> number of bytes from 63mTCP socket via socket descriptor <i>sockid</i> into the 64buffer starting at <i>buf.</i> It is the responsibility of 65the user to allocate memory for <i>buf</i> array.</p> 66 67<p style="margin-left:11%; margin-top: 1em">For cases when 68the total number of buffered unread bytes in the socket are 69less than <i>len,</i> <b>mtcp_read()</b> copies entire data 70to <i>buf</i> and returns the actual number of bytes that 71can be used by the application.</p> 72 73<p style="margin-left:11%; margin-top: 1em">An 74<b>mtcp_read</b>() call takes an additional argument named 75<i>mctx</i> that represents the per-core mTCP context in an 76application (see <b>mtcp_create_context()</b> for 77details).</p> 78 79<h2>RETURN VALUE 80<a name="RETURN VALUE"></a> 81</h2> 82 83 84<p style="margin-left:11%; margin-top: 1em">On success, the 85number of bytes read is returned. It is not an error if this 86number is smaller than the number of bytes requested; this 87may happen when the socket has fewer number of bytes 88buffered at that moment. On all errors, -1 is returned and 89<i>errno</i> is set 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="12%"> 101 102 103<p style="margin-top: 1em"><b>EBADF</b></p></td> 104<td width="3%"></td> 105<td width="74%"> 106 107 108<p style="margin-top: 1em">The socket descriptor 109<i>sockid</i> is invalid.</p></td></tr> 110<tr valign="top" align="left"> 111<td width="11%"></td> 112<td width="12%"> 113 114 115<p><b>ENOTSOCK</b></p></td> 116<td width="3%"></td> 117<td width="74%"> 118 119 120<p>The socket referred to by <i>sockid</i> has invalid 121<i>type</i></p> </td></tr> 122<tr valign="top" align="left"> 123<td width="11%"></td> 124<td width="12%"> 125 126 127<p><b>ENOTCONN</b></p></td> 128<td width="3%"></td> 129<td width="74%"> 130 131 132<p>Th socket referred to by <i>sockid</i> is in a TCP state 133that disallows read operations.</p></td></tr> 134<tr valign="top" align="left"> 135<td width="11%"></td> 136<td width="12%"> 137 138 139<p><b>EAGAIN</b></p></td> 140<td width="3%"></td> 141<td width="74%"> 142 143 144<p>The socket referred to by <i>sockid</i> does not have 145any available bytes in its buffer for reading.</p></td></tr> 146</table> 147 148<h2>AUTHORS 149<a name="AUTHORS"></a> 150</h2> 151 152 153<p style="margin-left:11%; margin-top: 1em">mOS 154development team <[email protected]></p> 155 156<h2>SEE ALSO 157<a name="SEE ALSO"></a> 158</h2> 159 160 161 162<p style="margin-left:11%; margin-top: 1em"><b>mtcp_bind</b>(), 163<b>mtcp_listen</b>(), <b>mtcp_accept</b>(), 164<b>mtcp_connect</b>(), <b>mtcp_socket</b>(), 165<b>mtcp_write</b>()</p> 166 167<h2>COLOPHON 168<a name="COLOPHON"></a> 169</h2> 170 171 172<p style="margin-left:11%; margin-top: 1em">This page is 173part of mOS release 0.3 <i>docs</i> section. A description 174of the project, and information about reporting bugs, can be 175found at http://mos.kaist.edu/.</p> 176<!--<hr>--> 177<br> 178<div class="footer"> 179 <img src="back-arrow.jpg" width="2%" height="2%"><a href="http://mos.kaist.edu/index_man.html">Back to Index</a> 180</div> 181</div> 182</body> 183</html> 184