Branch: Tag:

2005-02-01

2005-02-01 18:43:05 by Martin Stjernholm <mast@lysator.liu.se>

Doc some more. Set the port blocking again if the accept callback is
removed.

Rev: src/modules/files/socket.c:1.94

1929:   <span class='homogen--name'><b>accept</b></span>   </dt>   <dd><p><code><code class='object unresolved'>Stdio.File</code> <b><span class='method'>accept</span>(</b><b>)</b></code></p></dd> - </dl> +     -  + <dt class='head--doc'>Description</dt> + <dd class='body--doc'><p>Get the first connection request waiting for this port and return +  it as a connected socket.</p> + <p> If no connection request is waiting and the port is in nonblocking +  mode (i.e. an accept callback is installed) then zero is returned. +  Otherwise this function waits until a connection has arrived.</p> + </dd></dl>    -  +    <hr />   <dl class='group--doc'>   <dt class='head--type'><span class='homogen--type'>Method</span>
1940:   <dd><p><code><code class='datatype'>int</code> <b><span class='method'>bind</span>(</b><code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>void</code>|<code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>accept_callback</code>, <code class='datatype'>void</code>|<code class='datatype'>string</code> <code class='argument'>ip</code><b>)</b></code></p></dd>      <dt class='head--doc'>Description</dt> - <dd class='body--doc'><p>Bind opens a socket and binds it to port number on the local machine. -  If the second argument is present, the socket is set to nonblocking -  and the callback funcition is called whenever something connects to -  it. The callback will receive the id for this port as argument. -  Bind returns 1 on success, and zero on failiure.</p> - <p> If the optional argument 'ip' is given, bind will try to bind to -  this ip name or number.</p> + <dd class='body--doc'><p>Opens a socket and binds it to port number on the local machine. +  If the second argument is present, the socket is set to +  nonblocking and the callback funcition is called whenever +  something connects to it. The callback will receive the id for +  this port as argument and should typically call <code>accept</code> to +  establish a connection.</p> + <p> If the optional argument <code>ip</code> is given, <code>bind</code> will try to bind +  to an interface with that host name or IP number.</p>   </dd> -  + <dt class='head--doc'>Returns</dt> + <dd class='body--doc'><p>1 is returned on success, zero on failure. <code>errno</code> provides +  further details about the error in the latter case.</p> + </dd>   <dt class='head--doc'>See also</dt> - <dd class='body--doc'><p><code>accept</code></p> + <dd class='body--doc'><p><code>accept</code>, <code>set_id</code></p>   </dd></dl>      
1961:   <dd><p><code><code class='datatype'>int</code> <b><span class='method'>bind_unix</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code>, <code class='datatype'>void</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>Bind opens a Unix domain socket at the filesystem location path. -  If the second argument is present, the socket is set to nonblocking -  and the callback funcition is called whenever something connects to -  it. The callback will receive the id for this port as argument.</p> + <dd class='body--doc'><p>Opens a Unix domain socket at the given path in the file system. +  If the second argument is present, the socket is set to +  nonblocking and the callback funcition is called whenever +  something connects to it. The callback will receive the id for +  this port as argument and should typically call <code>accept</code> to +  establish a connection.</p>   </dd>   <dt class='head--doc'>Returns</dt> - <dd class='body--doc'><p>1 on success, and zero on failiure.</p> + <dd class='body--doc'><p>1 is returned on success, zero on failure. <code>errno</code> provides +  further details about the error in the latter case.</p>   </dd>   <dt class='head--doc'>Note</dt> - <dd class='body--doc'><p>this function is only available on systems that support Unix domain + <dd class='body--doc'><p>This function is only available on systems that support Unix domain    sockets.</p>   </dd>   <dt class='head--doc'>See also</dt> - <dd class='body--doc'><p><code>accept</code></p> + <dd class='body--doc'><p><code>accept</code>, <code>set_id</code></p>   </dd></dl>      
2017:   <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><code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>void</code>|<code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>accept_callback</code>, <code class='datatype'>void</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>, <code class='datatype'>void</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>When called with an int or any string except <code class='expr'>"stdin"</code> as +  first argument, this function does the same as <code>bind()</code> would do +  with the same arguments.</p> + <p> When called with <code class='expr'>"stdin"</code> as argument, a socket is created +  out of the file descriptor 0. This is only useful if that actually +  IS a socket to begin with.</p> + </dd> + <dt class='head--doc'>See also</dt> + <dd class='body--doc'><p><code>bind</code>, <code>listen_fd</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>If the last call done on this port failed, errno will return an -  integer describing what went wrong. Refer to your unix manual for -  further information.</p> + <dd class='body--doc'><p>If the last call done on this port failed, this function will +  return an integer describing what went wrong. Refer to your unix +  manual for further information.</p>   </dd></dl>      
2045:   <dd><p><code><code class='datatype'>int</code> <b><span class='method'>listen_fd</span>(</b><code class='datatype'>int</code> <code class='argument'>fd</code>, <code class='datatype'>void</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>This function does the same as port-&gt;bind, except that instead -  of creating a new socket and bind it to a port, it expects that -  the filedescriptor 'fd' is an already open port.</p> + <dd class='body--doc'><p>This function does the same as <code>bind</code>, except that instead of +  creating a new socket and bind it to a port, it expects the file +  descriptor <code>fd</code> to be an already open port.</p>   </dd>   <dt class='head--doc'>Note</dt>   <dd class='body--doc'><p>This function is only for the advanced user, and is generally used