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_write</title>
17<link rel="stylesheet" href="./common.css">
18</head>
19<body>
20<div class="main">
21<h1 align="center">mtcp_write</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_write
40&minus; send bytestream to 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&lt;mtcp_api.h&gt;</b></p>
49
50<p style="margin-left:11%; margin-top: 1em"><b>ssize_t
51mtcp_write(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_write</b>()
62sends up to <i>len</i> number of bytes from the buffer that
63is being pointed by <i>buf.</i> The bytestream is sent to
64the mTCP socket using the <i>sockid</i> descriptor.</p>
65
66<p style="margin-left:11%; margin-top: 1em">An
67<b>mtcp_write()</b> function call may write less number of
68bytes than <i>len</i> if there is insufficient space in the
69write buffer of the socket. In such a case, the return value
70is considered the actual number of bytes successfully
71written.</p>
72
73
74<p style="margin-left:11%; margin-top: 1em"><b>mtcp_write</b>()
75call takes an additional argument named <i>mctx</i> that
76represents the per-core mTCP context in an application (see
77<b>mtcp_create_context()</b> for details).</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 dispatched via the socket are returned. The
86number of bytes sent can be less than <i>count</i> if there
87is insufficient space in the write buffer of the socket. On
88error, -1 is returned 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>EAGAIN</b></p></td>
104<td width="3%"></td>
105<td width="74%">
106
107
108<p style="margin-top: 1em">The write buffer of the socket
109is currently full. The user should call the write function
110again once the write buffer has space available.</p></td></tr>
111<tr valign="top" align="left">
112<td width="11%"></td>
113<td width="12%">
114
115
116<p><b>EBADF</b></p></td>
117<td width="3%"></td>
118<td width="74%">
119
120
121<p><i>sockid</i> is not a valid socket descriptor for
122writing.</p> </td></tr>
123<tr valign="top" align="left">
124<td width="11%"></td>
125<td width="12%">
126
127
128<p><b>ENOTCONN</b></p></td>
129<td width="3%"></td>
130<td width="74%">
131
132
133<p>The underlying connection is not in a TCP state that
134allows data transmission (i.e. the TCP flow is neither in
135<b>ESTABLISHED</b> or <b>CLOSE_WAIT</b> state).</p></td></tr>
136<tr valign="top" align="left">
137<td width="11%"></td>
138<td width="12%">
139
140
141<p><b>ENOTSOCK</b></p></td>
142<td width="3%"></td>
143<td width="74%">
144
145
146<p>The socket referred to by <i>sockid</i> is not
147valid.</p> </td></tr>
148</table>
149
150<h2>AUTHORS
151<a name="AUTHORS"></a>
152</h2>
153
154
155<p style="margin-left:11%; margin-top: 1em">mOS
156development team &lt;[email protected]&gt;</p>
157
158<h2>SEE ALSO
159<a name="SEE ALSO"></a>
160</h2>
161
162
163
164<p style="margin-left:11%; margin-top: 1em"><b>mtcp_bind</b>(),
165<b>mtcp_listen</b>(), <b>mtcp_accept</b>(),
166<b>mtcp_connect</b>(), <b>mtcp_read</b>(),
167<b>mtcp_socket</b>()</p>
168
169<h2>COLOPHON
170<a name="COLOPHON"></a>
171</h2>
172
173
174<p style="margin-left:11%; margin-top: 1em">This page is
175part of mOS release 0.3 <i>docs</i> section. A description
176of the project, and information about reporting bugs, can be
177found at http://mos.kaist.edu/.</p>
178<!--<hr>-->
179<br>
180<div class="footer">
181  <img src="back-arrow.jpg" width="2%" height="2%"><a href="http://mos.kaist.edu/index_man.html">Back to Index</a>
182</div>
183</div>
184</body>
185</html>
186