121 lines
7.6 KiB
HTML
121 lines
7.6 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<!DOCTYPE html
|
||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html lang="en-us" xml:lang="en-us">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<meta name="security" content="public" />
|
||
|
<meta name="Robots" content="index,follow" />
|
||
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
||
|
<meta name="DC.Type" content="concept" />
|
||
|
<meta name="DC.Title" content="Nonblocking I/O" />
|
||
|
<meta name="abstract" content="When an application issues one of the socket input functions and there is no data to read, the function blocks and does not return until there is data to read." />
|
||
|
<meta name="description" content="When an application issues one of the socket input functions and there is no data to read, the function blocks and does not return until there is data to read." />
|
||
|
<meta name="DC.Relation" scheme="URI" content="aconcepts.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/fcntl.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/accept.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/ioctl.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/recv.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/send.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/connec.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/gsk_secure_soc_read.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/gsk_secure_soc_write.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/sslread.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/sslwrite.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/read.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/readv.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/recvfr.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/recvms.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/sendfile.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/sendf64.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/sendms.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/sendto.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/write.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="../apis/writev.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="xnonblock.htm" />
|
||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2001, 2006" />
|
||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2001, 2006" />
|
||
|
<meta name="DC.Format" content="XHTML" />
|
||
|
<meta name="DC.Identifier" content="cnonblock" />
|
||
|
<meta name="DC.Language" content="en-us" />
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
||
|
<title>Nonblocking I/O</title>
|
||
|
</head>
|
||
|
<body id="cnonblock"><a name="cnonblock"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Nonblocking I/O</h1>
|
||
|
<div><p>When an application issues one of the socket input functions and
|
||
|
there is no data to read, the function blocks and does not return until there
|
||
|
is data to read. </p>
|
||
|
<p>Similarly, an application can block on a socket output function when data
|
||
|
cannot be sent immediately. Finally, <span class="apiname">connect()</span> and <span class="apiname">accept()</span> can
|
||
|
block while waiting for connection establishment with the partner's programs.</p>
|
||
|
<p><img src="./delta.gif" alt="Start of change" />Sockets provide a method that enables application
|
||
|
programs to issue functions that block so that the function returns without
|
||
|
delay. This is done by either calling <span class="apiname">fcntl()</span> to turn on
|
||
|
the <strong>O_NONBLOCK</strong> flag, or calling <span class="apiname">ioctl()</span> to turn
|
||
|
on the <strong>FIONBIO</strong> flag. When running in this nonblocking mode, if a function
|
||
|
cannot be completed without blocking, it returns immediately. A <span class="apiname">connect()</span> might
|
||
|
return with [EINPROGRESS], which means that the connection initiation has
|
||
|
been started. You can then use the <span class="apiname">poll()</span> or <span class="apiname">select()</span> to
|
||
|
determine when the connection has been completed. For all other functions
|
||
|
that are affected by running in the nonblocking mode, an error code of [EWOULDBLOCK]
|
||
|
indicates that the call was unsuccessful.<img src="./deltaend.gif" alt="End of change" /></p>
|
||
|
<div class="p">You can use nonblocking with the following socket functions: <ul><li><span class="apiname">accept()</span></li>
|
||
|
<li><span class="apiname">connect()</span></li>
|
||
|
<li><span class="apiname">gsk_secure_soc_read()</span></li>
|
||
|
<li><span class="apiname">gsk_secure_soc_write()</span></li>
|
||
|
<li><span class="apiname">read()</span></li>
|
||
|
<li><span class="apiname">readv()</span></li>
|
||
|
<li><span class="apiname">recv()</span></li>
|
||
|
<li><span class="apiname">recvfrom()</span></li>
|
||
|
<li><span class="apiname">recvmsg()</span></li>
|
||
|
<li><span class="apiname">send()</span></li>
|
||
|
<li><span class="apiname">send_file()</span></li>
|
||
|
<li><span class="apiname">send_file64()</span></li>
|
||
|
<li><span class="apiname">sendmsg()</span></li>
|
||
|
<li><span class="apiname">sendto()</span></li>
|
||
|
<li><span class="apiname">SSL_Read()</span></li>
|
||
|
<li><span class="apiname">SSL_Write()</span></li>
|
||
|
<li><span class="apiname">write()</span></li>
|
||
|
<li><span class="apiname">writev()</span></li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="aconcepts.htm" title="Advanced socket concepts go beyond a general discussion of what sockets are and how they work. They provide ways to design socket applications for larger and more complex networks.">Advanced socket concepts</a></div>
|
||
|
</div>
|
||
|
<div class="relref"><strong>Related reference</strong><br />
|
||
|
<div><a href="xnonblock.htm" title="This sample program uses nonblocking and the select() API.">Example: Nonblocking I/O and select()</a></div>
|
||
|
</div>
|
||
|
<div class="relinfo"><strong>Related information</strong><br />
|
||
|
<div><a href="../apis/fcntl.htm">fnctl()</a></div>
|
||
|
<div><a href="../apis/accept.htm">accept()</a></div>
|
||
|
<div><a href="../apis/ioctl.htm">ioctl()</a></div>
|
||
|
<div><a href="../apis/recv.htm">recv()</a></div>
|
||
|
<div><a href="../apis/send.htm">send()</a></div>
|
||
|
<div><a href="../apis/connec.htm">connect()</a></div>
|
||
|
<div><a href="../apis/gsk_secure_soc_read.htm">gsk_secure_soc_read()</a></div>
|
||
|
<div><a href="../apis/gsk_secure_soc_write.htm">gsk_secure_soc_write()</a></div>
|
||
|
<div><a href="../apis/sslread.htm">SSL_Read()</a></div>
|
||
|
<div><a href="../apis/sslwrite.htm">SSL_Write()</a></div>
|
||
|
<div><a href="../apis/read.htm">read()</a></div>
|
||
|
<div><a href="../apis/readv.htm">readv()</a></div>
|
||
|
<div><a href="../apis/recvfr.htm">recvfrom()</a></div>
|
||
|
<div><a href="../apis/recvms.htm">recvmsg()</a></div>
|
||
|
<div><a href="../apis/sendfile.htm">send_file()</a></div>
|
||
|
<div><a href="../apis/sendf64.htm">send_file64()</a></div>
|
||
|
<div><a href="../apis/sendms.htm">sendmsg()</a></div>
|
||
|
<div><a href="../apis/sendto.htm">sendto()</a></div>
|
||
|
<div><a href="../apis/write.htm">write()</a></div>
|
||
|
<div><a href="../apis/writev.htm">writev()</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|