autodoc.git/
traditional_manual/
chapter_9.html
Branch:
Tag:
Non-build tags
All tags
No tags
2020-05-23
2020-05-23 13:10:51 by Marcus Comstedt <marcus@mc.pp.se>
6bbb87babc3f4c1a732fee1a2a1926265fa96f3e (
3089
lines) (+
513
/-
2576
)
[
Show
|
Annotate
]
Branch:
master
Thread.ResourceCount: Provide fallback implementation
594:
</dd> <dt><a name='9.5'></a> <h2 class='header'>9.5. Files and sockets</h2></dt>
-
<dd><
dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.File<
/
b></h2>
-
</dt><
dd>
<dl class='group--doc'>
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>This is the basic I/O object, it provides socket and pipe
-
communication as well as file access. It does not buffer reads and
-
writes by default, and provides no line-by-line reading, that is done
-
with <code>Stdio.FILE</code> object.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>The file or stream will normally be closed when this object is
-
destructed (unless there are more objects that refer to the same
-
file through use of <code>assign</code> or <code>dup</code>). Objects do not contain
-
cyclic references in themselves, so they will be destructed timely
-
when they run out of references.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>Stdio.FILE</code></p>
-
</dd></dl>
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>assign</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>assign</span>(</b><code class='object unresolved'>File</code>|<code class='object unresolved'>Fd</code> <code class='argument'>o</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>This function takes a clone of Stdio.File and assigns all
-
variables of this file from it. It can be used together with <code>dup()</code>
-
to move files around.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>dup()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>async_connect</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>async_connect</span>(</b><code class='datatype'>string</code> <code class='argument'>host</code>, <code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>function</code>(<code class='datatype'>int</code>, <code class='datatype'>mixed</code> ... :<code class='datatype'>void</code>) <code class='argument'>callback</code>, <code class='datatype'>mixed</code> ... <code class='argument'>args</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Open a TCP/IP connection asynchronously.</p>
-
<p> This function is similar to <code>connect()</code>, but works asynchronously.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-host'></span>Parameter <code class='parameter'>host</code></dt>
-
<dd></dd><dd class='body--doc'><p>Hostname or IP to connect to.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-port'></span>Parameter <code class='parameter'>port</code></dt>
-
<dd></dd><dd class='body--doc'><p>Port number or service name to connect to.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-callback'></span>Parameter <code class='parameter'>callback</code></dt>
-
<dd></dd><dd class='body--doc'><p>Function to be called on completion.
-
The first argument will be <code class='expr'>1</code> if a connection was
-
successfully established, and <code class='expr'>0</code> (zero) on failure.
-
The rest of the arguments to <code>callback</code> are passed
-
verbatim from <code>args</code>.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-args'></span>Parameter <code class='parameter'>args</code></dt>
-
<dd></dd><dd class='body--doc'><p>Extra arguments to pass to <code>callback</code>.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Returns <code class='expr'>0</code> on failure to open a socket, and <code class='expr'>1</code>
-
if <code>callback</code> will be used.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>The socket may be opened with <code>open_socket()</code> ahead of
-
the call to this function, but it is not required.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>This object is put in callback mode by this function. For
-
<code>callback</code> to be called, the backend must be active. See e.g.
-
<code>set_read_callback</code> for more details about backends and
-
callback mode.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>The socket will be in nonblocking state if the connection is
-
successful, and any callbacks will be cleared.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>connect()</code>, <code>open_socket()</code>, <code>set_nonblocking()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>close</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>close</span>(</b><b>)</b></code><br>
-
<code><code class='datatype'>int</code> <b><span class='method'>close</span>(</b><code class='datatype'>string</code> <code class='argument'>direction</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Close the file. Optionally, specify "r", "w" or "rw" to close just
-
the read, just the write or both read and write directions of the file
-
respectively.</p>
-
<p> An exception is thrown if an I/O error occurs.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Nonzero is returned if the file wasn't open in the specified
-
direction, zero otherwise.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>This function will not call the <tt>close_callback</tt>.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>open</code>, <code>open_socket</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>connect</b></span>
-
</dt>
-
<dd><p><code><code class='modifier'>variant</code> <code class='datatype'>int</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>host</code>, <code class='datatype'>int(0..)</code>|<code class='datatype'>string</code> <code class='argument'>port</code><b>)</b></code><br>
-
<code><code class='modifier'>variant</code> <code class='datatype'>int</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>host</code>, <code class='datatype'>int(0..)</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>string</code> <code class='argument'>client</code>, <code class='datatype'>int(0..)</code>|<code class='datatype'>string</code> <code class='argument'>client_port</code><b>)</b></code><br>
-
<code><code class='modifier'>variant</code> <code class='datatype'>string</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>host</code>, <code class='datatype'>int(0..)</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>string</code> <code class='argument'>data</code><b>)</b></code><br>
-
<code><code class='modifier'>variant</code> <code class='datatype'>string</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>host</code>, <code class='datatype'>int(0..)</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>int(0..0)</code>|<code class='datatype'>string</code> <code class='argument'>client</code>, <code class='datatype'>int(0..)</code>|<code class='datatype'>string</code> <code class='argument'>client_port</code>, <code class='datatype'>string</code> <code class='argument'>data</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Open a TCP/IP connection to the specified destination.</p>
-
<p> In nonblocking mode, success is indicated with the write-callback,
-
and failure with the close-callback or the read_oob-callback.</p>
-
<p> The <code>host</code> argument is the hostname or IP number of the remote
-
machine.</p>
-
<p> A local IP and port can be explicitly bound by specifying
-
<code>client</code> and <code>client_port</code>.</p>
-
<p> If the <code>data</code> argument is included the socket will use
-
TCP_FAST_OPEN if posible. In this mode the the function will
-
return the part of the data that has not been sent to the remote
-
server yet instead of 1 (you will have to use <code>write</code> to send
-
this data).</p>
-
<p> Note that TCP_FAST_OPEN requires server support, the connection
-
might fail even though the remote server exists. It might be
-
advisable to retry without TCP_FAST_OPEN (and remember this
-
fact)</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>This function returns 1 or the remaining <code>data</code> for success, 0
-
otherwise.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>In nonblocking mode <code class='expr'>0</code> (zero) may be returned and
-
<code>errno()</code> set to <code class='expr'>EWOULDBLOCK</code> or <code class='expr'>WSAEWOULDBLOCK</code>.</p>
-
<p> This should not be regarded as a
-
connection failure. In nonblocking mode you need to wait for a
-
write or close callback before you know if the connection failed
-
or not.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>query_address()</code>, <code>async_connect()</code>, <code>connect_unix()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>connect_unix</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>connect_unix</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Open a UNIX domain socket connection to the specified destination.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Returns <code class='expr'>1</code> on success, and <code class='expr'>0</code> on failure.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>Nonblocking mode is not supported while connecting</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>create</b></span>
-
</dt>
-
<dd><p><code><span class='object'>Stdio.File</span> <span class='class'>Stdio.File</span><b>(</b><b>)</b></code><br>
-
<code><span class='object'>Stdio.File</span> <span class='class'>Stdio.File</span><b>(</b><code class='datatype'>string</code> <code class='argument'>filename</code><b>)</b></code><br>
-
<code><span class='object'>Stdio.File</span> <span class='class'>Stdio.File</span><b>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>mode</code><b>)</b></code><br>
-
<code><span class='object'>Stdio.File</span> <span class='class'>Stdio.File</span><b>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>mode</code>, <code class='datatype'>int</code> <code class='argument'>mask</code><b>)</b></code><br>
-
<code><span class='object'>Stdio.File</span> <span class='class'>Stdio.File</span><b>(</b><code class='datatype'>string</code> <code class='argument'>descriptorname</code><b>)</b></code><br>
-
<code><span class='object'>Stdio.File</span> <span class='class'>Stdio.File</span><b>(</b><code class='datatype'>int</code> <code class='argument'>fd</code><b>)</b></code><br>
-
<code><span class='object'>Stdio.File</span> <span class='class'>Stdio.File</span><b>(</b><code class='datatype'>int</code> <code class='argument'>fd</code>, <code class='datatype'>string</code> <code class='argument'>mode</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>There are four basic ways to create a Stdio.File object.
-
The first is calling it without any arguments, in which case the you'd
-
have to call <code>open()</code>, <code>connect()</code> or some other method which connects
-
the File object with a stream.</p>
-
<p> The second way is calling it with a <code>filename</code> and open <code>mode</code>. This is
-
the same thing as cloning and then calling <code>open()</code>, except shorter and
-
faster.</p>
-
<p> The third way is to call it with <code>descriptorname</code> of <code class='expr'>"stdin"</code>,
-
<code class='expr'>"stdout"</code> or <code class='expr'>"stderr"</code>. This will open the specified
-
standard stream.</p>
-
<p> For the advanced users, you can use the file descriptors of the
-
systems (note: emulated by pike on some systems - like NT). This is
-
only useful for streaming purposes on unix systems. This is <b>not
-
recommended at all</b> if you don't know what you're into. Default
-
<code>mode</code> for this is <code class='expr'>"rw"</code>.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>Open mode will be filtered through the system UMASK. You
-
might need to use <code>chmod()</code> later.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>open()</code>, <code>connect()</code>, <code>Stdio.FILE</code>,</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>dup</b></span>
-
</dt>
-
<dd><p><code><code class='object unresolved'>File</code> <b><span class='method'>dup</span>(</b><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>This function returns a clone of Stdio.File with all variables
-
copied from this file.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>All variables, even <tt>id</tt>, are copied.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>assign()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>errno</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>errno</span>(</b><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Returns the error code for the last command on this file.
-
Error code is normally cleared when a command is successful.</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Inherit</span>
-
<span class='homogen--name'><b>Fd</b></span>
-
</dt>
-
<dd><p><code><span class='datatype'><code class='modifier'>optional</code> inherit Fd</span> : <span class='inherit'>Fd</span></code></p></dd>
-
</dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>line_iterator</b></span>
-
</dt>
-
<dd><p><code><code class='object unresolved'>String.SplitIterator</code>|<code class='object unresolved'>LineIterator</code> <b><span class='method'>line_iterator</span>(</b><code class='datatype'>int</code>|<code class='datatype'>void</code> <code class='argument'>trim</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Returns an iterator that will loop over the lines in this file.
-
If trim is true, all <tt>'\r'</tt> characters will be removed from
-
the input.</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>open</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>open</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>mode</code><b>)</b></code><br>
-
<code><code class='datatype'>int</code> <b><span class='method'>open</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>mode</code>, <code class='datatype'>int</code> <code class='argument'>mask</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Open a file for read, write or append. The parameter <code>mode</code> should
-
contain one or more of the following letters:</p>
-
<table class='box'><tr><td><code><code class='key'>"r"</code></code></td><td><p>Open file for reading.</p>
-
</td></tr>
-
<tr><td><code><code class='key'>"w"</code></code></td><td><p>Open file for writing.</p>
-
</td></tr>
-
<tr><td><code><code class='key'>"a"</code></code></td><td><p>Open file for append (use with <code class='expr'>"w"</code>).</p>
-
</td></tr>
-
<tr><td><code><code class='key'>"t"</code></code></td><td><p>Truncate file at open (use with <code class='expr'>"w"</code>).</p>
-
</td></tr>
-
<tr><td><code><code class='key'>"c"</code></code></td><td><p>Create file if it doesn't exist (use with <code class='expr'>"w"</code>).</p>
-
</td></tr>
-
<tr><td><code><code class='key'>"x"</code></code></td><td><p>Fail if file already exists (use with <code class='expr'>"c"</code>).</p>
-
</td></tr>
-
</table><p><code>mode</code> should always contain at least one of the letters
-
<code class='expr'>"r"</code> or <code class='expr'>"w"</code>.</p>
-
<p> The parameter <code>mask</code> is protection bits to use if the file is
-
created. Default is <code class='expr'>0666</code> (read+write for all in octal
-
notation).</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>This function returns <code class='expr'>1</code> for success, <code class='expr'>0</code> otherwise.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>close()</code>, <code>create()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>open_socket</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>open_socket</span>(</b><code class='datatype'>int</code>|<code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>port</code>, <code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>address</code>, <code class='datatype'>int</code>|<code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>family_hint</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>This makes this file into a socket ready for connections. The reason
-
for this function is so that you can set the socket to nonblocking
-
or blocking (default is blocking) before you call <code>connect()</code>.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-port'></span>Parameter <code class='parameter'>port</code></dt>
-
<dd></dd><dd class='body--doc'><p>If you give a port number to this function, the socket will be
-
bound to this port locally before connecting anywhere. This is
-
only useful for some silly protocols like <b>FTP</b>. The port can
-
also be specified as a string, giving the name of the service
-
associated with the port. Pass -1 to not specify a port (eg to
-
bind only to an address).</p>
-
</dd>
-
<dt class='head--doc'><span id='p-address'></span>Parameter <code class='parameter'>address</code></dt>
-
<dd></dd><dd class='body--doc'><p>You may specify an address to bind to if your machine has many IP
-
numbers.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-family_hint'></span>Parameter <code class='parameter'>family_hint</code></dt>
-
<dd></dd><dd class='body--doc'><p>A protocol family for the socket can be specified. If no family is
-
specified, one which is appropriate for the address is automatically
-
selected. Thus, there is normally no need to specify it. If you
-
do not want to specify a bind address, you can provide the address
-
as a hint here instead, to allow the automatic selection to work
-
anyway.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>This function returns 1 for success, 0 otherwise.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>connect()</code>, <code>set_nonblocking()</code>, <code>set_blocking()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>openat</b></span>
-
</dt>
-
<dd><p><code><code class='object unresolved'>File</code> <b><span class='method'>openat</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code><b>)</b></code><br>
-
<code><code class='object unresolved'>File</code> <b><span class='method'>openat</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>mode</code><b>)</b></code><br>
-
<code><code class='object unresolved'>File</code> <b><span class='method'>openat</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>mode</code>, <code class='datatype'>int</code> <code class='argument'>mask</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Open a file relative to an open directory.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>File.statat()</code>, <code>File.unlinkat()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>openpt</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>openpt</span>(</b><code class='datatype'>string</code> <code class='argument'>mode</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Open the master end of a pseudo-terminal pair. The parameter
-
<code>mode</code> should contain one or more of the following letters:</p>
-
<table class='box'><tr><td><code><code class='key'>"r"</code></code></td><td><p>Open terminal for reading.</p>
-
</td></tr>
-
<tr><td><code><code class='key'>"w"</code></code></td><td><p>Open terminal for writing.</p>
-
</td></tr>
-
</table><p><code>mode</code> should always contain at least one of the letters
-
<code class='expr'>"r"</code> or <code class='expr'>"w"</code>.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>grantpt()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>pipe</b></span>
-
</dt>
-
<dd><p><code><code class='object unresolved'>File</code> <b><span class='method'>pipe</span>(</b><code class='datatype'>void</code>|<code class='datatype'>int</code> <code class='argument'>required_properties</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>This function creates a pipe between the object it was called in
-
and an object that is returned.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-required_properties'></span>Parameter <code class='parameter'>required_properties</code></dt>
-
<dd></dd><dd class='body--doc'><p>Binary or (<code>predef::`|()</code>) of required <code class='expr'>PROP_</code> properties.</p>
-
<table class='box'><tr><td><code><code class='key'>PROP_IPC</code></code></td><td><p>The resulting pipe may be used for inter process communication.</p>
-
</td></tr>
-
<tr><td><code><code class='key'>PROP_NONBLOCK</code></code></td><td><p>The resulting pipe supports nonblocking I/O.</p>
-
</td></tr>
-
<tr><td><code><code class='key'>PROP_SHUTDOWN</code></code></td><td><p>The resulting pipe supports shutting down transmission in either
-
direction (see <code>close()</code>).</p>
-
</td></tr>
-
<tr><td><code><code class='key'>PROP_BUFFERED</code></code></td><td><p>The resulting pipe is buffered (usually 4KB).</p>
-
</td></tr>
-
<tr><td><code><code class='key'>PROP_BIDIRECTIONAL</code></code></td><td><p>The resulting pipe is bi-directional.</p>
-
</td></tr>
-
<tr><td><code><code class='key'>PROP_SEND_FD</code></code></td><td><p>The resulting pipe might support sending of file descriptors
-
(see <code>send_fd()</code> and <code>receive_fd()</code> for details).</p>
-
</td></tr>
-
<tr><td><code><code class='key'>PROP_TTY</code></code></td><td><p>The resulting pipe is a pseudo-tty.</p>
-
</td></tr>
-
<tr><td><code><code class='key'>PROP_REVERSE</code></code></td><td><p>The resulting pipe supports communication "backwards" (but
-
not necessarily "forwards", see <code>PROP_BIDIRECTIONAL</code>).</p>
-
</td></tr>
-
</table><p>The default is <code class='expr'>PROP_NONBLOCK|PROP_BIDIRECTIONAL</code>.</p>
-
<p> If <code>PROP_BIDIRECTIONAL</code> isn't specified, the read-end is this
-
object, and the write-end is the returned object (unless
-
<code>PROP_REVERSE</code> has been specified, in which case it is the other
-
way around).</p>
-
<p> The two ends of a bi-directional pipe are indistinguishable.</p>
-
<p> For <code>PROP_TTY</code> the returned object is the slave (unless
-
<code>PROP_REVERSE</code> has been specified).</p>
-
<p> If the File object this function is called in was open to begin with,
-
it will be closed before the pipe is created.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>Calling this function with an argument of <tt>0</tt> is not the
-
same as calling it with no arguments.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>Process.create_process()</code>, <code>send_fd()</code>, <code>receive_fd()</code>,
-
<code>PROP_IPC</code>, <code>PROP_NONBLOCK</code>, <code>PROP_SEND_FD</code>,
-
<code>PROP_SHUTDOWN</code>, <code>PROP_BUFFERED</code>, <code>PROP_REVERSE</code>,
-
<code>PROP_BIDIRECTIONAL</code>, <code>PROP_TTY</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>query_buffer_mode</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>array</code>(<code class='object unresolved'>Stdio.Buffer</code>|<code class='datatype'>int(0..0)</code>) <b><span class='method'>query_buffer_mode</span>(</b><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Get the active input and output buffers that have been
-
set with <code>set_buffer_mode()</code> (if any).</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Returns an array with two elements:</p>
-
<table class='box'><tr><td colspan='2'>Array</td></tr>
-
<tr><td><code><code class='object unresolved'>Stdio.Buffer</code> <code class='key'>0</code></code></td><td><p>The current input buffer.</p>
-
</td></tr>
-
<tr><td><code><code class='object unresolved'>Stdio.Buffer</code> <code class='key'>1</code></code></td><td><p>The current output buffer.</p>
-
</td></tr>
-
</table>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>set_buffer_mode()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>query_read_callback</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>query_write_callback</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>query_read_oob_callback</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>query_write_oob_callback</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>query_close_callback</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>query_callbacks</b></span><br>
-
</dt>
-
<dd><p><code><code class='object unresolved'>read_callback_t</code> <b><span class='method'>query_read_callback</span>(</b><b>)</b></code><br>
-
<code><code class='object unresolved'>write_callback_t</code> <b><span class='method'>query_write_callback</span>(</b><b>)</b></code><br>
-
<code><code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='datatype'>string</code>:<code class='datatype'>int</code>) <b><span class='method'>query_read_oob_callback</span>(</b><b>)</b></code><br>
-
<code><code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <b><span class='method'>query_write_oob_callback</span>(</b><b>)</b></code><br>
-
<code><code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <b><span class='method'>query_close_callback</span>(</b><b>)</b></code><br>
-
<code><code class='datatype'>array</code>(<code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='datatype'>void</code>|<code class='datatype'>string</code>:<code class='datatype'>int</code>)) <b><span class='method'>query_callbacks</span>(</b><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>These functions return the currently installed callbacks for the
-
respective events.</p>
-
<p> <code>query_callbacks</code> returns the callbacks in the same order as
-
<code>set_callbacks</code> and <code>set_nonblocking</code> expect them.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>set_nonblocking()</code>, <code>set_read_callback</code>,
-
<code>set_write_callback</code>, <code>set_read_oob_callback</code>,
-
<code>set_write_oob_callback</code>, <code>set_close_callback</code>,
-
<code>set_callbacks</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>query_id</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>mixed</code> <b><span class='method'>query_id</span>(</b><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>This function returns the <tt>id</tt> that has been set with <code>set_id()</code>.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>set_id()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>read</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>string(8bit)</code> <b><span class='method'>read</span>(</b><code class='datatype'>int</code>|<code class='datatype'>void</code> <code class='argument'>nbytes</code>, <code class='datatype'>bool</code>|<code class='datatype'>void</code> <code class='argument'>not_all</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Read (optionally buffered) data from a file or a stream.</p>
-
<p> Proxy function for <code>Fd::read()</code>, that adds support for
-
the buffering configured by <code>set_buffer_mode()</code></p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>read_function()</code>, <code>write()</code>, <code>Fd::read()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>read_function</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>function</code>(:<code class='datatype'>string</code>) <b><span class='method'>read_function</span>(</b><code class='datatype'>int</code> <code class='argument'>nbytes</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Returns a function that when called will call <code>read</code> with
-
nbytes as argument. Can be used to get various callback
-
functions, eg for the fourth argument to
-
<code>String.SplitIterator</code>.</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>send_fd</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>send_fd</span>(</b><code class='object unresolved'>File</code>|<code class='object unresolved'>Fd</code> <code class='argument'>file</code><b>)</b></code></p></dd>
-
</dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_blocking</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_blocking</span>(</b><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>This function clears all callbacks and sets a stream to blocking
-
mode. i.e. reading, writing and closing will wait until data has
-
been transferred before returning.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>The callbacks are cleared and blocking mode is set in one atomic
-
operation, so no callback gets called in between if the backend
-
is running in another thread.</p>
-
<p> Even so, if the stream is in callback mode (i.e. if any
-
callbacks are installed) then only the backend thread can use
-
this function reliably; it might otherwise already be running in
-
a callback which is about to call e.g. <code>write</code> when the stream
-
becomes blocking.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>set_nonblocking()</code>, <code>set_nonblocking_keep_callbacks()</code>,
-
<code>set_blocking_keep_callbacks()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_nonblocking_keep_callbacks</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_blocking_keep_callbacks</b></span><br>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_nonblocking_keep_callbacks</span>(</b><b>)</b></code><br>
-
<code><code class='datatype'>void</code> <b><span class='method'>set_blocking_keep_callbacks</span>(</b><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Toggle between blocking and nonblocking,
-
without changing the callbacks.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>set_nonblocking()</code>, <code>set_blocking()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_buffer_mode</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_buffer_mode</span>(</b><code class='object unresolved'>Stdio.Buffer</code>|<code class='datatype'>int(0..0)</code> <code class='argument'>in</code>, <code class='object unresolved'>Stdio.Buffer</code>|<code class='datatype'>int(0..0)</code> <code class='argument'>out</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Toggle the file to Buffer mode.</p>
-
<p> In this mode reading and writing will be done via Buffer
-
objects, in the directions you included buffers.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-in'></span>Parameter <code class='parameter'>in</code></dt>
-
<dd></dd><dd class='body--doc'><p>Input buffer. If this buffer is non-empty, its contents
-
will be returned after any already received data.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-out'></span>Parameter <code class='parameter'>out</code></dt>
-
<dd></dd><dd class='body--doc'><p>Output buffer. If this buffer is non-empty, its contents
-
will be sent after any data already queued for sending.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>Normally you call <code>write</code> to re-trigger the write callback if
-
you do not output anything in it (which will stop it from
-
re-occuring again).</p>
-
<p> This will work with buffered output mode as well, but simply
-
adding more data to the output buffer will work as well.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>query_buffer_mode()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_callbacks</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_callbacks</span>(</b><code class='object unresolved'>read_callback_t</code>|<code class='datatype'>void</code> <code class='argument'>read_cb</code>, <code class='object unresolved'>write_callback_t</code>|<code class='datatype'>void</code> <code class='argument'>write_cb</code>, <code class='datatype'>void</code>|<code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <code class='argument'>close_cb</code>, <code class='datatype'>void</code>|<code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='datatype'>string</code>:<code class='datatype'>int</code>) <code class='argument'>read_oob_cb</code>, <code class='datatype'>void</code>|<code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <code class='argument'>write_oob_cb</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Installs all the specified callbacks at once. Use <code>UNDEFINED</code>
-
to keep the current setting for a callback.</p>
-
<p> Like <code>set_nonblocking</code>, the callbacks are installed atomically.
-
As opposed to <code>set_nonblocking</code>, this function does not do
-
anything with the stream, and it doesn't even have to be open.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>set_read_callback</code>, <code>set_write_callback</code>,
-
<code>set_read_oob_callback</code>, <code>set_write_oob_callback</code>,
-
<code>set_close_callback</code>, <code>query_callbacks</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_read_callback</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_write_callback</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_read_oob_callback</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_write_oob_callback</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_close_callback</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_fs_event_callback</b></span><br>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_read_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='datatype'>string</code>:<code class='datatype'>int</code>) <code class='argument'>read_cb</code><b>)</b></code><br>
-
<code><code class='datatype'>void</code> <b><span class='method'>set_read_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='object unresolved'>Buffer</code>:<code class='datatype'>int</code>) <code class='argument'>read_cb</code><b>)</b></code><br>
-
<code><code class='datatype'>void</code> <b><span class='method'>set_write_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <code class='argument'>write_cb</code><b>)</b></code><br>
-
<code><code class='datatype'>void</code> <b><span class='method'>set_write_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='object unresolved'>Buffer</code>:<code class='datatype'>int</code>) <code class='argument'>write_cb</code><b>)</b></code><br>
-
<code><code class='datatype'>void</code> <b><span class='method'>set_read_oob_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='datatype'>string</code>:<code class='datatype'>int</code>) <code class='argument'>read_oob_cb</code><b>)</b></code><br>
-
<code><code class='datatype'>void</code> <b><span class='method'>set_write_oob_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <code class='argument'>write_oob_cb</code><b>)</b></code><br>
-
<code><code class='datatype'>void</code> <b><span class='method'>set_close_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <code class='argument'>close_cb</code><b>)</b></code><br>
-
<code><code class='datatype'>void</code> <b><span class='method'>set_fs_event_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='datatype'>int</code>:<code class='datatype'>int</code>) <code class='argument'>fs_event_cb</code>, <code class='datatype'>int</code> <code class='argument'>event_mask</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>These functions set the various callbacks, which will be called
-
when various events occur on the stream. A zero as argument will
-
remove the callback.</p>
-
<p> A <code>Pike.Backend</code> object is responsible for calling the
-
callbacks. It requires a thread to be waiting in it to execute
-
the calls. That means that only one of the callbacks will be
-
running at a time, so you don't need mutexes between them.</p>
-
<p> Unless you've specified otherwise with the <code>set_backend</code>
-
function, the default backend <code>Pike.DefaultBackend</code> will be
-
used. It's normally activated by returning <code class='expr'>-1</code> from the
-
<tt>main</tt> function and will then execute in the main thread.</p>
-
<ul>
-
<li><p>When data arrives on the stream, <code>read_cb</code> will be called with
-
some or all of that data as the second argument.</p>
-
<p> If the file is in buffer mode, the second argument will be a Buffer.</p>
-
<p> This will always be the same buffer, so data you do not use in
-
one read callback can be simply left in the buffer, when new
-
data arrives it will be appended</p>
-
</li><li><p>When the stream has buffer space over for writing, <code>write_cb</code>
-
will be called so that you can write more data to it.</p>
-
<p> This callback is also called after the remote end of a socket
-
connection has closed the write direction. An attempt to write
-
data to it in that case will generate a <code>System.EPIPE</code> errno.
-
If the remote end has closed both directions simultaneously
-
(the usual case), Pike will first attempt to call <code>close_cb</code>,
-
then this callback (unless <code>close_cb</code> has closed the stream).</p>
-
<p> If the file is in buffer mode, the second argument will be a Buffer.</p>
-
<p> You should add data to write to this buffer.</p>
-
</li><li><p>When out-of-band data arrives on the stream, <code>read_oob_cb</code>
-
will be called with some or all of that data as the second
-
argument.</p>
-
</li><li><p>When the stream allows out-of-band data to be sent,
-
<code>write_oob_cb</code> will be called so that you can write more
-
out-of-band data to it.</p>
-
<p> If the OS doesn't separate the write events for normal and
-
out-of-band data, Pike will try to call <code>write_oob_cb</code> first.
-
If it doesn't write anything, then <code>write_cb</code> will be tried.
-
This also means that <code>write_oob_cb</code> might get called when the
-
remote end of a connection has closed the write direction.</p>
-
</li><li><p>When an error or an end-of-stream in the read direction
-
occurs, <code>close_cb</code> will be called. <code>errno</code> will return the
-
error, or zero in the case of an end-of-stream.</p>
-
<p> The name of this callback is rather unfortunate since it
-
really has nothing to do with a close: The stream is still
-
open when <code>close_cb</code> is called (you might not be able to read
-
and/or write to it, but you can still use things like
-
<code>query_address</code>, and the underlying file descriptor is still
-
allocated). Also, this callback will not be called for a local
-
close, neither by a call to <code>close</code> or by destructing this
-
object.</p>
-
<p> Also, <code>close_cb</code> will not be called if a remote close only
-
occurs in the write direction; that is handled by <code>write_cb</code>
-
(or possibly <code>write_oob_cb</code>).</p>
-
<p> Events to <code>read_cb</code> and <code>close_cb</code> will be automatically
-
deregistered if an end-of-stream occurs, and all events in the
-
case of an error. I.e. there won't be any more calls to the
-
callbacks unless they are reinstalled. This doesn't affect the
-
callback settings - <code>query_read_callback</code> et al will still
-
return the installed callbacks.</p>
-
</li></ul><p>If the stream is a socket performing a nonblocking connect (see
-
<code>open_socket</code> and <code>connect</code>), a connection failure will call
-
<code>close_cb</code>, and a successful connect will call either
-
<code>read_cb</code> or <code>write_cb</code> as above.</p>
-
<p> All callbacks will receive the <tt>id</tt> set by <code>set_id</code> as
-
first argument.</p>
-
<p> If a callback returns <code class='expr'>-1</code>, no other callback or call out
-
will be called by the backend in that round. I.e. the caller of
-
the backend will get control back right away. For the default
-
backend that means it will immediately start another round and
-
check files and call outs anew.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-event_mask'></span>Parameter <code class='parameter'>event_mask</code></dt>
-
<dd></dd><dd class='body--doc'><p>An event mask specifing bitwise OR of one or more event types to
-
monitor, selected from <code>Stdio.NOTE_WRITE</code> and friends.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>These functions do not set the file nonblocking.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>Callbacks are also set by <code>set_callbacks</code> and
-
<code>set_nonblocking()</code>.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>After a callback has been called, it's disabled until it has
-
accessed the stream accordingly, i.e. the <code>write_cb</code> callback
-
is disabled after it's been called until something has been
-
written with <code>write</code>, and the <code>write_oob_cb</code> callback is
-
likewise disabled until something has been written with
-
<code>write_oob</code>. Since the data already has been read when the read
-
callbacks are called, this effect is not noticeable for them.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>Installing callbacks means that you will start doing I/O on the
-
stream from the thread running the backend. If you are running
-
these set functions from another thread you must be prepared
-
that the callbacks can be called immediately by the backend
-
thread, so it might not be safe to continue using the stream in
-
this thread.</p>
-
<p> Because of that, it's useful to talk about "callback mode" when
-
any callback is installed. In callback mode the stream should be
-
seen as "bound" to the backend thread. For instance, it's only
-
the backend thread that reliably can end callback mode before
-
the stream is "handed over" to another thread.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>Callback mode has nothing to do with nonblocking mode - although
-
the two often are used together they don't have to be.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>The file object will stay referenced from the backend object as
-
long as there are callbacks that can receive events.</p>
-
</dd>
-
<dt class='head--doc'>Bugs</dt>
-
<dd class='body--doc'><p>Setting a close callback without a read callback currently only
-
works when there's no risk of getting more data on the stream.
-
Otherwise the close callback will be silently deregistered if
-
data arrives.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>fs_event callbacks only trigger on systems that support these events.
-
Currently, this includes systems that use kqueue, such as Mac OS X,
-
and various flavours of BSD.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>set_callbacks</code>, <code>set_nonblocking()</code>, <code>set_id()</code>,
-
<code>set_backend</code>, <code>query_read_callback</code>, <code>query_write_callback</code>,
-
<code>query_read_oob_callback</code>, <code>query_write_oob_callback</code>,
-
<code>query_close_callback</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_id</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_id</span>(</b><code class='datatype'>mixed</code> <code class='argument'>id</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>This function sets the <tt>id</tt> of this file. The <tt>id</tt> is mainly
-
used as an identifier that is sent as the first argument to all
-
callbacks. The default <tt>id</tt> is <code class='expr'>0</code> (zero). Another possible
-
use of the <tt>id</tt> is to hold all data related to this file in a
-
mapping or array.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>query_id()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_nonblocking</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_nonblocking</span>(</b><code class='object unresolved'>read_callback_t</code> <code class='argument'>read_callback</code>, <code class='object unresolved'>write_callback_t</code> <code class='argument'>write_callback</code>, <code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <code class='argument'>close_callback</code><b>)</b></code><br>
-
<code><code class='datatype'>void</code> <b><span class='method'>set_nonblocking</span>(</b><code class='object unresolved'>read_callback_t</code> <code class='argument'>read_callback</code>, <code class='object unresolved'>write_callback_t</code> <code class='argument'>write_callback</code>, <code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <code class='argument'>close_callback</code>, <code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='datatype'>string</code>:<code class='datatype'>int</code>) <code class='argument'>read_oob_callback</code>, <code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <code class='argument'>write_oob_callback</code><b>)</b></code><br>
-
<code><code class='datatype'>void</code> <b><span class='method'>set_nonblocking</span>(</b><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>This function sets a stream to nonblocking mode and installs the
-
specified callbacks. See the <code class='expr'>set_*_callback</code> functions
-
for details about them. If no arguments are given, the callbacks
-
will be cleared.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>As opposed to calling the set callback functions separately,
-
this function will set all the callbacks and nonblocking mode
-
atomically so that no callback gets called in between. That
-
avoids races in case the backend is executed by another thread.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>Out-of-band data was not be supported on Pike 0.5 and earlier,
-
and not on Pike 0.6 through 7.4 if they were compiled with the
-
option <tt>'--without-oob'</tt>.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>set_blocking()</code>, <code>set_callbacks</code>, <code>set_read_callback()</code>,
-
<code>set_write_callback()</code>, <code>set_read_oob_callback()</code>,
-
<code>set_write_oob_callback()</code>, <code>set_close_callback()</code>
-
<code>set_nonblocking_keep_callbacks()</code>,
-
<code>set_blocking_keep_callbacks()</code></p>
-
</dd></dl>
-
</dd></dl><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.FILE</b></h2>
-
</dt><dd><dl class='group--doc'>
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p><code>Stdio.FILE</code> is a buffered version of <code>Stdio.File</code>, it inherits
-
<code>Stdio.File</code> and has most of the functionality of <code>Stdio.File</code>.
-
However, it has an input buffer that allows line-by-line input.</p>
-
<p> It also has support for automatic charset conversion for both input
-
and output (see <code>Stdio.FILE()->set_charset()</code>).</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>The output part of <code>Stdio.FILE</code> is currently not buffered.</p>
-
</dd></dl>
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>_get_iterator</b></span>
-
</dt>
-
<dd><p><code><span class='class'>Stdio.FILE</span> <span class='method'>a</span>;<br>
-
foreach( a; index; value ) or<br></code><code><code class='modifier'>protected</code> <code class='datatype'>object</code> <b><span class='method'>_get_iterator</span>(</b><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Returns an iterator that will loop over the lines in this file.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>line_iterator()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>getchar</b></span>
-
</dt>
-
<dd><p><code><code class='modifier'>local</code> <code class='datatype'>int</code> <b><span class='method'>getchar</span>(</b><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>This function returns one character from the input stream.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Returns the ISO-10646 (Unicode) value of the character.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>Returns an <code class='expr'>int</code> and not a <code class='expr'>string</code> of length 1.</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>gets</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>string</code> <b><span class='method'>gets</span>(</b><code class='datatype'>bool</code>|<code class='datatype'>void</code> <code class='argument'>not_all</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Read one line of input with support for input conversion.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-not_all'></span>Parameter <code class='parameter'>not_all</code></dt>
-
<dd></dd><dd class='body--doc'><p>Set this parameter to ignore partial lines at EOF. This
-
is useful for eg monitoring a growing logfile.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>This function returns the line read if successful, and <code class='expr'>0</code> if
-
no more lines are available.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>ngets()</code>, <code>read()</code>, <code>line_iterator()</code>, <code>set_charset()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Inherit</span>
-
<span class='homogen--name'><b>file</b></span>
-
</dt>
-
<dd><p><code><span class='datatype'>inherit File</span> : <span class='inherit'>file</span></code></p></dd>
-
</dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>line_iterator</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>object</code> <b><span class='method'>line_iterator</span>(</b><code class='datatype'>int</code>|<code class='datatype'>void</code> <code class='argument'>trim</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Returns an iterator that will loop over the lines in this file.
-
If <code>trim</code> is true, all <tt>'\r'</tt> characters will be removed
-
from the input.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>It's not supported to call this method more than once
-
unless a call to <code>seek</code> is done in advance. Also note that it's
-
not possible to intermingle calls to <code>read</code>, <code>gets</code> or other
-
functions that read data with the line iterator, it will produce
-
unexpected results since the internal buffer in the iterator will not
-
contain sequential file-data in those cases.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>_get_iterator()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>ngets</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>array</code>(<code class='datatype'>string</code>) <b><span class='method'>ngets</span>(</b><code class='datatype'>void</code>|<code class='datatype'>int(1..)</code> <code class='argument'>n</code>, <code class='datatype'>bool</code>|<code class='datatype'>void</code> <code class='argument'>not_all</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Get <code>n</code> lines.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-n'></span>Parameter <code class='parameter'>n</code></dt>
-
<dd></dd><dd class='body--doc'><p>Number of lines to get, or all remaining if zero.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-not_all'></span>Parameter <code class='parameter'>not_all</code></dt>
-
<dd></dd><dd class='body--doc'><p>Set this parameter to ignore partial lines at EOF. This
-
is useful for eg monitoring a growing logfile.</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>openat</b></span>
-
</dt>
-
<dd><p><code><code class='object unresolved'>FILE</code> <b><span class='method'>openat</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code><b>)</b></code><br>
-
<code><code class='object unresolved'>FILE</code> <b><span class='method'>openat</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>mode</code><b>)</b></code><br>
-
<code><code class='object unresolved'>FILE</code> <b><span class='method'>openat</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>mode</code>, <code class='datatype'>int</code> <code class='argument'>mask</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Same as <code>Stdio.File()->openat()</code>, but returns an <code>Stdio.FILE</code>
-
object.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>Stdio.File()->openat()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>pipe</b></span>
-
</dt>
-
<dd><p><code><code class='object unresolved'>FILE</code> <b><span class='method'>pipe</span>(</b><code class='datatype'>void</code>|<code class='datatype'>int</code> <code class='argument'>flags</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Same as <code>Stdio.File()->pipe()</code>, but returns an <code>Stdio.FILE</code>
-
object.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>Stdio.File()->pipe()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>printf</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>printf</span>(</b><code class='datatype'>string</code> <code class='argument'>format</code>, <code class='datatype'>mixed</code> ... <code class='argument'>data</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>This function does approximately the same as:
-
<code class='expr'><code>write</code>(<code>sprintf</code>(<code>format</code>,@<code>data</code>))</code>.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>write()</code>, <code>sprintf()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>read</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>string</code> <b><span class='method'>read</span>(</b><code class='datatype'>int</code>|<code class='datatype'>void</code> <code class='argument'>bytes</code>, <code class='datatype'>void</code>|<code class='datatype'>bool</code> <code class='argument'>now</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Read <code>bytes</code> (wide-) characters with buffering and support for
-
input conversion.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>Stdio.File()->read()</code>, <code>set_charset()</code>, <code>unread()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_charset</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_charset</span>(</b><code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>charset</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Sets the input and output charset of this file to the specified
-
<code>charset</code>. If <code>charset</code> is 0 or not specified the environment
-
is used to try to detect a suitable charset.</p>
-
<p> The default charset if this function is not called is
-
<tt>"ISO-8859-1"</tt>.</p>
-
</dd><dt class='head--fixme'>FIXME</dt>
-
<dd class='body--fixme'><p>Consider using one of
-
ISO-IR-196 (<tt>"\e%G"</tt> - switch to UTF-8 with return)
-
or ISO-IR-190 (<tt>"\e%/G"</tt> - switch to UTF-8 level 1 no return)
-
or ISO-IR-191 (<tt>"\e%/H"</tt> - switch to UTF-8 level 2 no return)
-
or ISO-IR-192 (<tt>"\e%/I"</tt> - switch to UTF-8 level 3 no return)
-
or ISO-IR-193 (<tt>"\e%/J"</tt> - switch to UTF-16 level 1 no return)
-
or ISO-IR-194 (<tt>"\e%/K"</tt> - switch to UTF-16 level 2 no return)
-
or ISO-IR-195 (<tt>"\e%/L"</tt> - switch to UTF-16 level 3 no return)
-
or ISO-IR-162 (<tt>"\e%/@"</tt> - switch to UCS-2 level 1)
-
or ISO-IR-163 (<tt>"\e%/A"</tt> - switch to UCS-4 level 1)
-
or ISO-IR-174 (<tt>"\e%/C"</tt> - switch to UCS-2 level 2)
-
or ISO-IR-175 (<tt>"\e%/D"</tt> - switch to UCS-4 level 2)
-
or ISO-IR-176 (<tt>"\e%/E"</tt> - switch to UCS-2 level 3)
-
or ISO-IR-177 (<tt>"\e%/F"</tt> - switch to UCS-4 level 3)
-
or ISO-IR-178 (<tt>"\e%B"</tt> - switch to UTF-1)
-
automatically to encode wide strings.</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>ungets</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>ungets</span>(</b><code class='datatype'>string</code> <code class='argument'>s</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>This function puts a line back in the input buffer. The line
-
can then be read with eg <code>read()</code>, <code>gets()</code> or <code>getchar()</code>.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>The string is autoterminated by an extra line-feed.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>read()</code>, <code>gets()</code>, <code>getchar()</code>, <code>unread()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>unread</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>unread</span>(</b><code class='datatype'>string</code> <code class='argument'>s</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>This function puts a string back in the input buffer. The string
-
can then be read with eg <code>read()</code>, <code>gets()</code> or <code>getchar()</code>.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>read()</code>, <code>gets()</code>, <code>getchar()</code>, <code>ungets()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>write</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>write</span>(</b><code class='datatype'>array</code>(<code class='datatype'>string</code>)|<code class='datatype'>string</code> <code class='argument'>what</code>, <code class='datatype'>mixed</code> ... <code class='argument'>fmt</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Write <code>what</code> with support for output_conversion.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>Stdio.File()->write()</code></p>
-
</dd></dl>
-
</dd></dl></dd>
+
<dd></dd>
<dt><a name='9.6'></a> <h2 class='header'>9.6. Ports and UDP</h2></dt>
-
<dd><
dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.Port<
/
b></h2>
-
</dt><
dd>
<dl class='group--doc'>
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Handles listening to socket ports. Whenever you need a bound
-
socket that is open and listens for connections you should
-
use this program.</p>
-
</dd></dl>
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>accept</b></span>
-
</dt>
-
<dd><p><code><code class='object unresolved'>File</code> <b><span class='method'>accept</span>(</b><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>This function completes a connection made from a remote machine to
-
this port. It returns a two-way stream in the form of a clone of
-
<code>Stdio.File</code>. The new file is by initially set to blocking mode.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>Stdio.File</code>, <code>fd_factory()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>create</b></span>
-
</dt>
-
<dd><p><code><span class='object'>Stdio.Port</span> <span class='class'>Stdio.Port</span><b>(</b><b>)</b></code><br>
-
<code><span class='object'>Stdio.Port</span> <span class='class'>Stdio.Port</span><b>(</b><code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code><b>)</b></code><br>
-
<code><span class='object'>Stdio.Port</span> <span class='class'>Stdio.Port</span><b>(</b><code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>accept_callback</code><b>)</b></code><br>
-
<code><span class='object'>Stdio.Port</span> <span class='class'>Stdio.Port</span><b>(</b><code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>accept_callback</code>, <code class='datatype'>string</code> <code class='argument'>ip</code><b>)</b></code><br>
-
<code><span class='object'>Stdio.Port</span> <span class='class'>Stdio.Port</span><b>(</b><code class='argument'>"stdin"</code><b>)</b></code><br>
-
<code><span class='object'>Stdio.Port</span> <span class='class'>Stdio.Port</span><b>(</b><code class='argument'>"stdin"</code>, <code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>accept_callback</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>If the first argument is other than <code class='expr'>"stdin"</code> the arguments will
-
be passed to <code>bind()</code>.</p>
-
<p> When create is called with <code class='expr'>"stdin"</code> as the first argument, a
-
socket is created out of the file descriptor <code class='expr'>0</code>. This is only
-
useful if it actually is a socket to begin with, and is equivalent to
-
creating a port and initializing it with <code>listen_fd</code>(0).</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>bind</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>fd_factory</b></span>
-
</dt>
-
<dd><p><code><code class='modifier'>protected</code> <code class='object unresolved'>Fd</code> <b><span class='method'>fd_factory</span>(</b><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Factory creating empty <code>Fd</code> objects.</p>
-
<p> This function is called by <code>accept()</code> when it needs to create
-
a new file.</p>
-
<p> The default implementation returns the <code>Fd</code> inherit in
-
an empty <code>File</code> object.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>accept()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Inherit</span>
-
<span class='homogen--name'><b>_port</b></span>
-
</dt>
-
<dd><p><code><span class='datatype'>inherit _port</span> : <span class='inherit'>_port</span></code></p></dd>
-
</dl>
-
</dd></dl><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.UDP</b></h2>
-
</dt><dd><dl class='group--doc'>
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>UDP (User Datagram Protocol) handling.</p>
-
</dd></dl>
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Inherit</span>
-
<span class='homogen--name'><b>UDP</b></span>
-
</dt>
-
<dd><p><code><span class='datatype'>inherit _Stdio.UDP</span> : <span class='inherit'>UDP</span></code></p></dd>
-
</dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_nonblocking</b></span>
-
</dt>
-
<dd><p><code><code class='object unresolved'>UDP</code> <b><span class='method'>set_nonblocking</span>(</b><b>)</b></code><br>
-
<code><code class='object unresolved'>UDP</code> <b><span class='method'>set_nonblocking</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mapping</code>(<code class='datatype'>string</code>:<code class='datatype'>int</code>|<code class='datatype'>string</code>), <code class='datatype'>mixed</code> ... :<code class='datatype'>void</code>) <code class='argument'>read_cb</code>, <code class='datatype'>mixed</code> ... <code class='argument'>extra_args</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Set this object to nonblocking mode.</p>
-
<p> If <code>read_cb</code> and <code>extra_args</code> are specified, they will be passed on
-
to <code>set_read_callback()</code>.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>The called object.</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_read_callback</b></span>
-
</dt>
-
<dd><p><code><code class='object unresolved'>UDP</code> <b><span class='method'>set_read_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mapping</code>(<code class='datatype'>string</code>:<code class='datatype'>int</code>|<code class='datatype'>string</code>), <code class='datatype'>mixed</code> ... :<code class='datatype void'>void</code>) <code class='argument'>read_cb</code>, <code class='datatype'>mixed</code> ... <code class='argument'>extra_args</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>The <code>read_cb</code> function will receive a mapping similar to the mapping
-
returned by <code>read()</code>:</p>
-
<table class='box'><tr><td><code><code class='key'>"data"</code> : <code class='datatype'>string</code></code></td><td><p>Received data.</p>
-
</td></tr>
-
<tr><td><code><code class='key'>"ip"</code> : <code class='datatype'>string</code></code></td><td><p>Data was sent from this IP.</p>
-
</td></tr>
-
<tr><td><code><code class='key'>"port"</code> : <code class='datatype'>int</code></code></td><td><p>Data was sent from this port.</p>
-
</td></tr>
-
</table>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>The called object.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>read()</code></p>
-
</dd></dl>
-
</dd></dl></dd>
+
<dd></dd>
<dt><a name='9.7'></a> <h2 class='header'>9.7. Terminal I/O</h2></dt> <dd><dl><dt><h2 class='header'>Module <b class='ms datatype'>Stdio.Terminfo</b></h2>
3221:
<dt><a name='9.8'></a> <h2 class='header'>9.8. Other</h2></dt> <dd><dl><dt><h2 class='header'>Module <b class='ms datatype'>Stdio</b></h2>
-
</dt><dd>
-
-
<
hr />
-
<
dl
class='group--doc'
>
-
<dt
class='head--type'
><
span class='homogen--type'>Constant</span>
-
<span class='homogen--name'><b>DATA_CHUNK_SIZE</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'><code class='modifier'>final</code> constant</code> <code class='datatype'>int</code> Stdio.<code class='constant'>DATA_CHUNK_SIZE</code></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Size used in various places to divide incoming or outgoing data
-
into chunks.</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Constant</span>
-
<span class='homogen--name'><b>TCSADRAIN</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>constant</code> <code class='datatype'>string</code> Stdio.<code class='constant'>TCSADRAIN</code></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Argument to <code>Stdio.File()->tcsetattr()</code>.</p>
-
<p> Change after all output has been written.</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Constant</span>
-
<span class='homogen--name'><b>TCSAFLUSH</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>constant</code> <code class='datatype'>string</code> Stdio.<code class='constant'>TCSAFLUSH</code></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Argument to <code>Stdio.File()->tcsetattr()</code>.</p>
-
<p> Change after all output has been written,
-
and empty the input buffers.</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Constant</span>
-
<span class='homogen--name'><b>TCSANOW</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>constant</code> <code class='datatype'>string</code> Stdio.<code class='constant'>TCSANOW</code></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Argument to <code>Stdio.File()->tcsetattr()</code>.</p>
-
<p> Change immediately.</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>append_file</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>append_file</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>str</code>, <code class='datatype'>int</code>|<code class='datatype'>void</code> <code class='argument'>access</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Append the string <code>str</code> onto the file <code>filename</code>.</p>
-
<p> For a description of <code>access</code>, see <code>Stdio.File->open()</code>.</p>
-
</dd>
-
<dt class='head--doc'>Throws</dt>
-
<dd class='body--doc'><p>Throws an error if <code>filename</code> couldn't be opened for writing.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Returns the number of bytes written, i.e. <code class='expr'>sizeof(str)</code>.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>write_file()</code>, <code>read_bytes()</code>, <code>Stdio.File()->open()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>append_path</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>append_path_unix</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>append_path_nt</b></span><br>
-
</dt>
-
<dd><p><code><code class='datatype'>string</code> <b><span class='method'>append_path</span>(</b><code class='datatype'>string</code> <code class='argument'>absolute</code>, <code class='datatype'>string</code> ... <code class='argument'>relative</code><b>)</b></code><br>
-
<code><code class='datatype'>string</code> <b><span class='method'>append_path_unix</span>(</b><code class='datatype'>string</code> <code class='argument'>absolute</code>, <code class='datatype'>string</code> ... <code class='argument'>relative</code><b>)</b></code><br>
-
<code><code class='datatype'>string</code> <b><span class='method'>append_path_nt</span>(</b><code class='datatype'>string</code> <code class='argument'>absolute</code>, <code class='datatype'>string</code> ... <code class='argument'>relative</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Append <code>relative</code> paths to an <code>absolute</code> path and remove any
-
<code class='expr'>"//"</code>, <code class='expr'>"../"</code> or <code class='expr'>"/."</code> to produce a
-
straightforward absolute path as a result.</p>
-
<p> <code class='expr'>"../"</code> is ignorded in the relative paths if it makes the
-
created path begin with something else than the absolute path
-
(or so far created path).</p>
-
<p> <code>append_path_nt()</code> fixes drive letter issues in <code>relative</code>
-
by removing the colon separator <code class='expr'>":"</code> if it exists (k:/fnord appends
-
as k/fnord)</p>
-
<p> <code>append_path_nt()</code> also makes sure that UNC path(s) in <code>relative</code> is appended
-
correctly by removing any <code class='expr'>"\\"</code> or <code class='expr'>"//"</code> from the beginning.</p>
-
<p> <code>append_path()</code> is equivalent to <code>append_path_unix()</code> on UNIX-like
-
operating systems, and equivalent to <code>append_path_nt()</code> on NT-like
-
operating systems.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>combine_path()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>async_cp</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>async_cp</span>(</b><code class='datatype'>string</code> <code class='argument'>from</code>, <code class='datatype'>string</code> <code class='argument'>to</code>, <code class='datatype'>function</code>(<code class='datatype'>int</code>, <code class='datatype'>mixed</code> ... :<code class='datatype'>void</code>) <code class='argument'>callback</code>, <code class='datatype'>mixed</code> ... <code class='argument'>args</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Copy a file asynchronously.</p>
-
<p> This function is similar to <code>cp()</code>, but works asynchronously.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-from'></span>Parameter <code class='parameter'>from</code></dt>
-
<dd></dd><dd class='body--doc'><p>Name of file to copy.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-to'></span>Parameter <code class='parameter'>to</code></dt>
-
<dd></dd><dd class='body--doc'><p>Name of file to create or replace with a copy of <code>from</code>.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-callback'></span>Parameter <code class='parameter'>callback</code></dt>
-
<dd></dd><dd class='body--doc'><p>Function to be called on completion.
-
The first argument will be <code class='expr'>1</code> on success, and <code class='expr'>0</code> (zero)
-
otherwise. The rest of the arguments to <code>callback</code> are passed
-
verbatim from <code>args</code>.</p>
-
</dd>
-
<dt class='head--doc'><span id='p-args'></span>Parameter <code class='parameter'>args</code></dt>
-
<dd></dd><dd class='body--doc'><p>Extra arguments to pass to <code>callback</code>.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>For <code>callback</code> to be called, the backend must be active (ie
-
<code>main()</code> must have returned <code class='expr'>-1</code>, or <code>Pike.DefaultBackend</code>
-
get called in some other way). The actual copying may start
-
before the backend has activated.</p>
-
</dd>
-
<dt class='head--doc'>Bugs</dt>
-
<dd class='body--doc'><p>Currently the file sizes are not compared, so the destination file
-
(<code>to</code>) may be truncated.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>cp()</code>, <code>sendfile()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>convert_modestring2int</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>convert_modestring2int</span>(</b><code class='datatype'>string</code> <code class='argument'>mode_string</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Convert the mode_string string as returned by Stdio.Stat object
-
to int suitable for chmod</p>
-
</dd>
-
<dt class='head--doc'><span id='p-mode_string'></span>Parameter <code class='parameter'>mode_string</code></dt>
-
<dd></dd><dd class='body--doc'><p>The string as return from Stdio.Stat()->mode_string</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>An int matching the permission of the mode_string string suitable for
-
chmod</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>cp</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>cp</span>(</b><code class='datatype'>string</code> <code class='argument'>from</code>, <code class='datatype'>string</code> <code class='argument'>to</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Copies the file <code>from</code> to the new position <code>to</code>. If there is
-
no system function for cp, a new file will be created and the
-
old one copied manually in chunks of <code>DATA_CHUNK_SIZE</code> bytes.</p>
-
<p> This function can also copy directories recursively.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>0 on error, 1 on success</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>This function keeps file and directory mode bits, unlike in Pike
-
7.6 and earlier.</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>exist</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>exist</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Check if a <code>path</code> exists.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Returns true if the given path exists (is a directory or file),
-
otherwise false.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>May fail with eg <code>errno()</code> <tt>EFBIG</tt> if the file exists,
-
but the filesystem doesn't support the file size.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>is_dir()</code>, <code>is_file()</code>, <code>is_link()</code>, <code>file_stat()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>file_equal</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>file_equal</span>(</b><code class='datatype'>string</code> <code class='argument'>file_1</code>, <code class='datatype'>string</code> <code class='argument'>file_2</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Returns nonzero if the given paths are files with identical
-
content, returns zero otherwise. Zero is also returned for any
-
sort of I/O error.</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>file_size</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>file_size</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Give the size of a file. Size -1 indicates that the file either
-
does not exist, or that it is not readable by you. Size -2
-
indicates that it is a directory, -3 that it is a symlink and -4
-
that it is a device.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>file_stat()</code>, <code>write_file()</code>, <code>read_bytes()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Inherit</span>
-
<span class='homogen--name'><b>_Stdio</b></span>
-
</dt>
-
<dd><p><code><span class='datatype'>inherit _Stdio</span> : <span class='inherit'>_Stdio</span></code></p></dd>
-
</dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>is_dir</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>is_dir</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Check if a <code>path</code> is a directory.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Returns true if the given path is a directory, otherwise false.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>exist()</code>, <code>is_file()</code>, <code>is_link()</code>, <code>file_stat()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>is_file</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>is_file</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Check if a <code>path</code> is a file.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Returns true if the given path is a regular file, otherwise false.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>exist()</code>, <code>is_dir()</code>, <code>is_link()</code>, <code>file_stat()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>is_link</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>is_link</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Check if a <code>path</code> is a symbolic link.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Returns true if the given path is a symbolic link, otherwise false.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>exist()</code>, <code>is_dir()</code>, <code>is_file()</code>, <code>file_stat()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>mkdirhier</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>mkdirhier</span>(</b><code class='datatype'>string</code> <code class='argument'>pathname</code>, <code class='datatype'>void</code>|<code class='datatype'>int</code> <code class='argument'>mode</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Creates zero or more directories to ensure that the given <code>pathname</code> is
-
a directory.</p>
-
<p> If a <code>mode</code> is given, it's used for the new directories after being &'ed
-
with the current umask (on OS'es that support this).</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Returns zero on failure and nonzero on success.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>mkdir()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>perror</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>perror</span>(</b><code class='datatype'>string</code> <code class='argument'>s</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>This function prints a message to stderr along with a description
-
of what went wrong if available. It uses the system errno to find
-
out what went wrong, so it is only applicable to IO errors.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>werror()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>read_bytes</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>string</code> <b><span class='method'>read_bytes</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>int</code> <code class='argument'>start</code>, <code class='datatype'>int</code> <code class='argument'>len</code><b>)</b></code><br>
-
<code><code class='datatype'>string</code> <b><span class='method'>read_bytes</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>int</code> <code class='argument'>start</code><b>)</b></code><br>
-
<code><code class='datatype'>string</code> <b><span class='method'>read_bytes</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Read <code>len</code> number of bytes from a regular file <code>filename</code>
-
starting at byte <code>start</code>, and return it as a string.</p>
-
<p> If <code>len</code> is omitted, the rest of the file will be returned.</p>
-
<p> If <code>start</code> is also omitted, the entire file will be returned.</p>
-
</dd>
-
<dt class='head--doc'>Throws</dt>
-
<dd class='body--doc'><p>Throws an error on any I/O error except when the file doesn't
-
exist.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Returns <code class='expr'>0</code> (zero) if the file doesn't exist or if
-
<code>start</code> is beyond the end of it.</p>
-
<p> Returns a string with the requested data otherwise.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>read_file</code>, <code>write_file()</code>, <code>append_file()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Typedef</span>
-
<span class='homogen--name'><b>read_callback_t</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'><code class='modifier'>local</code> typedef</code> <code class='datatype'>function</code>(<code class='datatype'>mixed</code>|<code class='datatype'>void</code>, <code class='datatype'>string</code>:<code class='datatype'>int</code>|<code class='datatype'>void</code>)|<code class='datatype'>function</code>(<code class='datatype'>mixed</code>|<code class='datatype'>void</code>, <code class='object unresolved'>Buffer</code>:<code class='datatype'>int</code>|<code class='datatype'>void</code>)|<code class='datatype'>function</code>(<code class='datatype'>mixed</code>|<code class='datatype'>void</code>:<code class='datatype'>int</code>|<code class='datatype'>void</code>) Stdio.<code class='typedef'>read_callback_t</code></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>The various read_callback signatures.</p>
-
<p> The string (or void) version is used when buffer mode (see
-
<code>set_buffer_mode</code>) has not been enabled for reading.</p>
-
<p> The <code>Buffer</code> version is used when a <code>Buffer</code> has been enabled
-
for reading.</p>
-
<p> In both cases the data is the newly arrived data, but in buffered
-
mode data you did not fully read in the last read callback is
-
kept in the buffer.</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>read_file</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>string</code> <b><span class='method'>read_file</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code><b>)</b></code><br>
-
<code><code class='datatype'>string</code> <b><span class='method'>read_file</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>int</code> <code class='argument'>start</code>, <code class='datatype'>int</code> <code class='argument'>len</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Read <code>len</code> lines from a regular file <code>filename</code> after skipping
-
<code>start</code> lines and return those lines as a string. If both
-
<code>start</code> and <code>len</code> are omitted the whole file is read.</p>
-
</dd>
-
<dt class='head--doc'>Throws</dt>
-
<dd class='body--doc'><p>Throws an error on any I/O error except when the file doesn't
-
exist.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Returns <code class='expr'>0</code> (zero) if the file doesn't exist or if
-
<code>start</code> is beyond the end of it.</p>
-
<p> Returns a string with the requested data otherwise.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>read_bytes()</code>, <code>write_file()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>recursive_mv</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>recursive_mv</span>(</b><code class='datatype'>string</code> <code class='argument'>from</code>, <code class='datatype'>string</code> <code class='argument'>to</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Copy a file or a directory tree by copying and then
-
removing. Mode bits are preserved in the copy.
-
It's not the fastest but works on every OS and
-
works well across different file systems.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Returns 0 on failure, nonzero otherwise.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>recursive_rm</code> <code>cp</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>recursive_rm</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>recursive_rm</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Remove a file or a directory tree.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Returns 0 on failure, nonzero otherwise.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>rm</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>sendfile</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>object</code> <b><span class='method'>sendfile</span>(</b><code class='datatype'>array</code>(<code class='datatype'>string</code>) <code class='argument'>headers</code>, <code class='object unresolved'>File</code> <code class='argument'>from</code>, <code class='datatype'>int</code> <code class='argument'>offset</code>, <code class='datatype'>int</code> <code class='argument'>len</code>, <code class='datatype'>array</code>(<code class='datatype'>string</code>) <code class='argument'>trailers</code>, <code class='object unresolved'>File</code> <code class='argument'>to</code><b>)</b></code><br>
-
<code><code class='datatype'>object</code> <b><span class='method'>sendfile</span>(</b><code class='datatype'>array</code>(<code class='datatype'>string</code>) <code class='argument'>headers</code>, <code class='object unresolved'>File</code> <code class='argument'>from</code>, <code class='datatype'>int</code> <code class='argument'>offset</code>, <code class='datatype'>int</code> <code class='argument'>len</code>, <code class='datatype'>array</code>(<code class='datatype'>string</code>) <code class='argument'>trailers</code>, <code class='object unresolved'>File</code> <code class='argument'>to</code>, <code class='datatype'>function</code>(<code class='datatype'>int</code>, <code class='datatype'>mixed</code> ... :<code class='datatype'>void</code>) <code class='argument'>callback</code>, <code class='datatype'>mixed</code> ... <code class='argument'>args</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Sends <code>headers</code> followed by <code>len</code> bytes starting at <code>offset</code>
-
from the file <code>from</code> followed by <code>trailers</code> to the file <code>to</code>.
-
When completed <code>callback</code> will be called with the total number of
-
bytes sent as the first argument, followed by <code>args</code>.</p>
-
<p> Any of <code>headers</code>, <code>from</code> and <code>trailers</code> may be left out
-
by setting them to <code class='expr'>0</code>.</p>
-
<p> Setting <code>offset</code> to <code class='expr'>-1</code> means send from the current position in
-
<code>from</code>.</p>
-
<p> Setting <code>len</code> to <code class='expr'>-1</code> means send until <code>from</code>'s end of file is
-
reached.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>The sending is performed asynchronously, and may complete
-
both before and after the function returns.</p>
-
<p> For <code>callback</code> to be called, the backend must be active (ie
-
<code>main()</code> must have returned <code class='expr'>-1</code>, or <code>Pike.DefaultBackend</code>
-
get called in some other way).</p>
-
<p> In some cases, the backend must also be active for any sending to
-
be performed at all.</p>
-
<p> In Pike 7.4.496, Pike 7.6.120 and Pike 7.7 and later the backend
-
associated with <code>to</code> will be used rather than the default backend.
-
Note that you usually will want <code>from</code> to have the same backend as <code>to</code>.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>The low-level sending may be performed with blocking I/O calls, and
-
thus trigger the process being killed with <tt>SIGPIPE</tt> when the
-
peer closes the other end. Add a call to <code>signal()</code> to avoid this.</p>
-
</dd>
-
<dt class='head--doc'>Bugs</dt>
-
<dd class='body--doc'><p>FIXME: Support for timeouts?</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>Stdio.File->set_nonblocking()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>simplify_path</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>string</code> <b><span class='method'>simplify_path</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Returns a canonic representation of <code>path</code> (without /./, /../, //
-
and similar path segments).</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Variable</span>
-
<span class='homogen--name'><b>stderr</b></span>
-
</dt>
-
<dd><p><code><code class='object unresolved'>FILE</code> Stdio.<b><span class='variable'>stderr</span></b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>An instance of <tt>FILE("stderr")</tt>, the standard error stream. Use this
-
when you want to output error messages.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>predef::werror()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Variable</span>
-
<span class='homogen--name'><b>stdin</b></span>
-
</dt>
-
<dd><p><code><code class='object unresolved'>FILE</code> Stdio.<b><span class='variable'>stdin</span></b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>An instance of <tt>FILE("stdin")</tt>, the standard input stream. Use this
-
when you want to read anything from the standard input.
-
This example will read lines from standard input for as long as there
-
are more lines to read. Each line will then be written to stdout together
-
with the line number. We could use <code>Stdio.stdout.write()</code> instead
-
of just <code>write()</code>, since they are the same function.</p>
-
</dd>
-
<dt class='head--doc'>Example</dt>
-
<dd class='example'><pre><p>int main()
-
{
-
int line;
-
while(string s=Stdio.stdin.gets())
-
write("%5d: %s\n", line++, s);
-
}</p>
-
</pre></dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Variable</span>
-
<span class='homogen--name'><b>stdout</b></span>
-
</dt>
-
<dd><p><code><code class='object unresolved'>FILE</code> Stdio.<b><span class='variable'>stdout</span></b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>An instance of <tt>FILE("stdout")</tt>, the standatd output stream. Use this
-
when you want to write anything to the standard output.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>predef::write()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>werror</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>werror</span>(</b><code class='datatype'>string</code> <code class='argument'>s</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Write a message to stderr. Stderr is normally the console, even if
-
the process output has been redirected to a file or pipe.</p>
-
</dd>
-
<dt class='head--doc'>Note</dt>
-
<dd class='body--doc'><p>This function is identical to <code>predef::werror()</code>.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>predef::werror()</code></p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Typedef</span>
-
<span class='homogen--name'><b>write_callback_t</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'><code class='modifier'>local</code> typedef</code> <code class='datatype'>function</code>(<code class='datatype'>mixed</code>|<code class='datatype'>void</code>:<code class='datatype'>int</code>|<code class='datatype'>void</code>)|<code class='datatype'>function</code>(<code class='datatype'>mixed</code>|<code class='datatype'>void</code>, <code class='object unresolved'>Buffer</code>:<code class='datatype'>int</code>|<code class='datatype'>void</code>) Stdio.<code class='typedef'>write_callback_t</code></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>The various write_callback signatures.</p>
-
<p> The void version is used when buffer mode (see
-
<code>set_buffer_mode</code>) has not been enabled for writing.</p>
-
<p> The <code>Buffer</code> version is used when a <code>Buffer</code> has been enabled
-
for writing, add data to that buffer to send it.</p>
-
</dd></dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>write_file</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>write_file</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>str</code>, <code class='datatype'>int</code>|<code class='datatype'>void</code> <code class='argument'>access</code><b>)</b></code></p></dd>
-
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>Write the string <code>str</code> onto the file <code>filename</code>. Any existing
-
data in the file is overwritten.</p>
-
<p> For a description of <code>access</code>, see <code>Stdio.File()->open()</code>.</p>
-
</dd>
-
<dt class='head--doc'>Throws</dt>
-
<dd class='body--doc'><p>Throws an error if <code>filename</code> couldn't be opened for writing.</p>
-
</dd>
-
<dt class='head--doc'>Returns</dt>
-
<dd class='body--doc'><p>Returns the number of bytes written, i.e. <code class='expr'>sizeof(str)</code>.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>append_file()</code>, <code>read_bytes()</code>, <code>Stdio.File()->open()</code></p>
-
</dd></dl>
-
<dl><dt><
h2 class='header'>Class <b class='ms datatype'>Stdio.
BlockFile
</b></h2>
+
</dt><dd><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.
FakeFile
</b></h2>
</dt><dd><dl class='group--doc'> <dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>The Stdio.BlockFile API.</p>
-
<p> This class exists purely for typing reasons.</p>
-
<p> Use in types in place of <code>Stdio.File</code> where only blocking
-
I/O is done with the object.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>Stream</code>, <code>NonblockingStream</code>, <code>File</code>, <code>FILE</code></p>
-
</dd></dl>
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Inherit</span>
-
<span class='homogen--name'><b>Stream</b></span>
-
</dt>
-
<dd><p><code><span class='datatype'>inherit Stream</span> : <span class='inherit'>Stream</span></code></p></dd>
-
</dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>seek</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>seek</span>(</b><code class='datatype'>int</code> <code class='argument'>to</code>, <code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>how</code><b>)</b></code></p></dd>
-
</dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>tell</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>tell</span>(</b><b>)</b></code></p></dd>
-
</dl>
-
</dd></dl><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.FakeFile</b></h2>
-
</dt><dd><dl class='group--doc'>
-
<dt class='head--doc'>Description</dt>
+
<dd class='body--doc'><p>A string wrapper that pretends to be a <code>Stdio.File</code> object in addition to some features of a <code>Stdio.FILE</code> object.</p> </dd></dl>
4773:
<dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>tcgetattr()</code>, <code>tcsetattr()</code></p> </dd></dl>
-
</dd></dl><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.NonblockingStream</b></h2>
-
</dt><dd><dl class='group--doc'>
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>The Stdio.NonblockingStream API.</p>
-
<p> This class exists purely for typing reasons.</p>
-
<p> Use in types in place of <code>Stdio.File</code> where nonblocking and/or
-
blocking stream-oriented I/O is done with the object.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>Stream</code>, <code>BlockFile</code>, <code>File</code>, <code>FILE</code></p>
-
</dd></dl>
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Inherit</span>
-
<span class='homogen--name'><b>Stream</b></span>
-
</dt>
-
<dd><p><code><span class='datatype'>inherit Stream</span> : <span class='inherit'>Stream</span></code></p></dd>
-
</dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_blocking</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_blocking</span>(</b><b>)</b></code></p></dd>
-
</dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_read_callback</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_write_callback</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_close_callback</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_fs_event_callback</b></span><br>
-
</dt>
-
<dd><p><code><code class='object unresolved'>NonblockingStream</code> <b><span class='method'>set_read_callback</span>(</b><code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>f</code>, <code class='datatype'>mixed</code> ... <code class='argument'>rest</code><b>)</b></code><br>
-
<code><code class='object unresolved'>NonblockingStream</code> <b><span class='method'>set_write_callback</span>(</b><code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>f</code>, <code class='datatype'>mixed</code> ... <code class='argument'>rest</code><b>)</b></code><br>
-
<code><code class='object unresolved'>NonblockingStream</code> <b><span class='method'>set_close_callback</span>(</b><code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>f</code>, <code class='datatype'>mixed</code> ... <code class='argument'>rest</code><b>)</b></code><br>
-
<code><code class='object unresolved'>NonblockingStream</code> <b><span class='method'>set_fs_event_callback</span>(</b><code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>f</code>, <code class='datatype'>int</code> <code class='argument'>event_mask</code>, <code class='datatype'>mixed</code> ... <code class='argument'>rest</code><b>)</b></code></p></dd>
-
</dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_nonblocking</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_nonblocking</span>(</b><code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>a</code>, <code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>b</code>, <code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>c</code>, <code class='datatype'>function</code>(:<code class='datatype void'>void</code>)|<code class='datatype'>void</code> <code class='argument'>d</code>, <code class='datatype'>function</code>(:<code class='datatype void'>void</code>)|<code class='datatype'>void</code> <code class='argument'>e</code><b>)</b></code></p></dd>
-
</dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_read_oob_callback</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>set_write_oob_callback</b></span><br>
-
</dt>
-
<dd><p><code><code class='modifier'>optional</code> <code class='object unresolved'>NonblockingStream</code> <b><span class='method'>set_read_oob_callback</span>(</b><code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>f</code>, <code class='datatype'>mixed</code> ... <code class='argument'>rest</code><b>)</b></code><br>
-
<code><code class='modifier'>optional</code> <code class='object unresolved'>NonblockingStream</code> <b><span class='method'>set_write_oob_callback</span>(</b><code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>f</code>, <code class='datatype'>mixed</code> ... <code class='argument'>rest</code><b>)</b></code></p></dd>
-
</dl>
-
</dd></dl><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.Stream</b></h2>
-
</dt><dd><dl class='group--doc'>
-
<dt class='head--doc'>Description</dt>
-
<dd class='body--doc'><p>The Stdio.Stream API.</p>
-
<p> This class exists purely for typing reasons.</p>
-
<p> Use in types in place of <code>Stdio.File</code> where only blocking
-
stream-oriented I/O is done with the object.</p>
-
<p> This class lists the minimum functionality guaranteed to exist in
-
all Stream objects.</p>
-
</dd>
-
<dt class='head--doc'>See also</dt>
-
<dd class='body--doc'><p><code>NonblockingStream</code>, <code>BlockFile</code>, <code>File</code>, <code>FILE</code></p>
-
</dd></dl>
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>close</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>void</code> <b><span class='method'>close</span>(</b><b>)</b></code></p></dd>
-
</dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>read</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>string</code> <b><span class='method'>read</span>(</b><code class='datatype'>int</code> <code class='argument'>nbytes</code><b>)</b></code></p></dd>
-
</dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>read_oob</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>write_oob</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>tcgetattr</b></span><br>
-
<span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>tcsetattr</b></span><br>
-
</dt>
-
<dd><p><code><code class='modifier'>optional</code> <code class='datatype'>string</code> <b><span class='method'>read_oob</span>(</b><code class='datatype'>int</code> <code class='argument'>nbytes</code><b>)</b></code><br>
-
<code><code class='modifier'>optional</code> <code class='datatype'>int</code> <b><span class='method'>write_oob</span>(</b><code class='datatype'>string</code> <code class='argument'>data</code><b>)</b></code><br>
-
<code><code class='modifier'>optional</code> <code class='datatype'>mapping</code>(<code class='datatype'>string</code>:<code class='datatype'>int</code>) <b><span class='method'>tcgetattr</span>(</b><b>)</b></code><br>
-
<code><code class='modifier'>optional</code> <code class='datatype'>int</code> <b><span class='method'>tcsetattr</span>(</b><code class='datatype'>mapping</code>(<code class='datatype'>string</code>:<code class='datatype'>int</code>) <code class='argument'>attr</code>, <code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>when</code><b>)</b></code></p></dd>
-
</dl>
-
-
-
<hr />
-
<dl class='group--doc'>
-
<dt class='head--type'><span class='homogen--type'>Method</span>
-
<span class='homogen--name'><b>write</b></span>
-
</dt>
-
<dd><p><code><code class='datatype'>int</code> <b><span class='method'>write</span>(</b><code class='datatype'>string</code> <code class='argument'>data</code><b>)</b></code></p></dd>
-
</dl>
+
</dd></dl><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.sendfile</b></h2> </dt><dd><dl class='group--doc'> <dt class='head--doc'>Description</dt>