1<!-- Creator     : groff version 1.22.2 -->
2<!-- CreationDate: Wed Feb  1 23:55:12 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
18</head>
19<body>
20
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
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_write
41&minus; send bytestream to an mTCP socket</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&lt;mtcp_api.h&gt;</b></p>
50
51<p style="margin-left:11%; margin-top: 1em"><b>ssize_t
52mtcp_write(mctx_t</b> <i>mctx</i><b>, int</b>
53<i>sockid</i><b>, char *</b><i>buf</i><b>, size_t</b>
54<i>len</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_write</b>()
63sends up to <i>len</i> number of bytes from the buffer that
64is being pointed by <i>buf.</i> The bytestream is sent to
65the mTCP socket using the <i>sockid</i> descriptor.</p>
66
67<p style="margin-left:11%; margin-top: 1em">An
68<b>mtcp_write()</b> function call may write less number of
69bytes than <i>len</i> if there is insufficient space in the
70write buffer of the socket. In such a case, the return value
71is considered the actual number of bytes successfully
72written.</p>
73
74
75<p style="margin-left:11%; margin-top: 1em"><b>mtcp_write</b>()
76call takes an additional argument named <i>mctx</i> that
77represents the per-core mTCP context in an application (see
78<b>mtcp_create_context()</b> for details).</p>
79
80<h2>RETURN VALUE
81<a name="RETURN VALUE"></a>
82</h2>
83
84
85<p style="margin-left:11%; margin-top: 1em">On success, the
86number of bytes dispatched via the socket are returned. The
87number of bytes sent can be less than <i>count</i> if there
88is insufficient space in the write buffer of the socket. On
89error, -1 is returned and <i>errno</i> is set
90appropriately.</p>
91
92<h2>ERRORS
93<a name="ERRORS"></a>
94</h2>
95
96
97<table width="100%" border="0" rules="none" frame="void"
98       cellspacing="0" cellpadding="0">
99<tr valign="top" align="left">
100<td width="11%"></td>
101<td width="12%">
102
103
104<p style="margin-top: 1em"><b>EAGAIN</b></p></td>
105<td width="3%"></td>
106<td width="74%">
107
108
109<p style="margin-top: 1em">The write buffer of the socket
110is currently full. The user should call the write function
111again once the write buffer has space available.</p></td></tr>
112<tr valign="top" align="left">
113<td width="11%"></td>
114<td width="12%">
115
116
117<p><b>EBADF</b></p></td>
118<td width="3%"></td>
119<td width="74%">
120
121
122<p><i>sockid</i> is not a valid socket descriptor for
123writing.</p> </td></tr>
124<tr valign="top" align="left">
125<td width="11%"></td>
126<td width="12%">
127
128
129<p><b>ENOTCONN</b></p></td>
130<td width="3%"></td>
131<td width="74%">
132
133
134<p>The underlying connection is not in a TCP state that
135allows data transmission (i.e. the TCP flow is neither in
136<b>ESTABLISHED</b> or <b>CLOSE_WAIT</b> state).</p></td></tr>
137<tr valign="top" align="left">
138<td width="11%"></td>
139<td width="12%">
140
141
142<p><b>ENOTSOCK</b></p></td>
143<td width="3%"></td>
144<td width="74%">
145
146
147<p>The socket referred to by <i>sockid</i> is not
148valid.</p> </td></tr>
149</table>
150
151<h2>AUTHORS
152<a name="AUTHORS"></a>
153</h2>
154
155
156<p style="margin-left:11%; margin-top: 1em">mOS development
157team &lt;[email protected]&gt;</p>
158
159<h2>SEE ALSO
160<a name="SEE ALSO"></a>
161</h2>
162
163
164
165<p style="margin-left:11%; margin-top: 1em"><b>mtcp_bind</b>(),
166<b>mtcp_listen</b>(), <b>mtcp_accept</b>(),
167<b>mtcp_connect</b>(), <b>mtcp_read</b>(),
168<b>mtcp_socket</b>()</p>
169
170<h2>COLOPHON
171<a name="COLOPHON"></a>
172</h2>
173
174
175<p style="margin-left:11%; margin-top: 1em">This page is
176part of mOS release 0.3 <i>docs</i> section. A description
177of the project, and information about reporting bugs, can be
178found at http://mos.kaist.edu/.</p>
179<hr>
180</body>
181</html>
182