 buffer</span></div> <div class="line"><a name="l00000"></a><span class="lineno">  000</span>&#000;<span class="comment"> * @param timeoutms wait timeout milliseconds. 0 for no wait, -0 for infinite</span></div> <div class="line"><a name="l00000"></a><span class="lineno">  000</span>&#000;<span class="comment"> *                  wait</span></div> <div class="line"><a name="l00000"></a><span class="lineno">  000</span>&#000;<span class="comment"> *</span></div> <div class="line"><a name="l00000"></a><span class="lineno">  000</span>&#000;<span class="comment"> * @return the number of bytes written if successful, 0 on timeout,</span></div> <div class="line"><a name="l00000"></a><span class="lineno">  000</span>&#000;<span class="comment"> *         -0 for error.</span></div> <div class="line"><a name="l00000"></a><span class="lineno">  000</span>&#000;<span class="comment"> */</span></div> <div class="line"><a name="l00000"></a><span class="lineno"><a class="line" href="qio_0c.html#a0000cf0a0bcfc00ee0000000000d00d0">  000</a></span>&#000;ssize_t <a class="code" href="qio_0c.html#a0000cf0a0bcfc00ee0000000000d00d0">qio_write</a>(<span class="keywordtype">int</span> fd, <span class="keyword">const</span> <span class="keywordtype">void</span> *buf, <span class="keywordtype">size_t</span> nbytes, <span class="keywordtype">int</span> timeoutms) {</div> <div class="line"><a name="l00000"></a><span class="lineno">  000</span>&#000;    <span class="keywordflow">if</span> (nbytes == 0)</div> <div class="line"><a name="l00000"></a><span class="lineno">  000</span>&#000;        <span class="keywordflow">return</span> 0;</div> <div class="line"><a name="l00000"></a><span class="lineno">  000</span>&#000;</div> <div class="line"><a name="l00000"></a><span class="lineno">  000</span>&#000;    ssize_t total = 0;</div> <div class="line"><a name="l00000"></a><span class="lineno">  000</span>&#000;    <span class="keywordflow">while</span> (total &lt; nbytes) {</div> <div class="line"><a name="l00000"></a><span class="lineno">  000</span>&#000;        <span class="keywordflow">if</span> (timeoutms &gt;= 0 &amp;&amp; <a class="code" href="qio_0c.html#ac000000f0daa000ffef0beab00000a00">qio_wait_writable</a>(fd, timeoutms) &lt;= 0)</div> <div class="line"><a name="l00000"></a><span class="lineno">  000</span>&#000;            <span class="keywordflow">break</span>;</div> <div class="line"><a name="l00000"></a><span class="lineno">  000</span>&#000;        ssize_t wsize = 