@ciao-lang/ts-ciao-interface
Version:
Simple Ciao interface for node.
146 lines • 36.3 kB
HTML
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><meta name="theme-color" content="#273f79"/><link rel="stylesheet" href="lpdoc.css" type="text/css"/><script type="text/javascript" src="lpdoc.js"></script><title>The socket interface — The Ciao System v1.22</title></head><body><div class="lpdoc-page fixleftbar"><a href="#" id="sidebar-toggle-button" class="lpdoc-navbutton"><span id="sidebar-button-arrow">☰</span></a><div id="sidebar" class="lpdoc-sidebar"><div style="height: 40px; margin-left: auto; margin-right: auto"><img src="ciao-logo_autofig.png" width=auto height=100%></div><div class="lpdoc-nav"><span class="lpdoc-on-right"><a class="lpdoc-navbutton" href="ExtraLibs.html">↑</a><a class="lpdoc-navbutton" href="random_aggregates.html">←</a><a class="lpdoc-navbutton" href="sockets_io.html">→</a><a class="lpdoc-navbutton" href="ciaosearch.html">🔍</a></span><span><a href="ciaofulltoc.html">TOC</a></span></div><hr></hr><ul class="lpdoc-itemize-sectpath"><li><a href="ciao.html">The Ciao System</a> »<br/> </li><li><a href="ExtraLibs.html">PART VIII - Additional libraries</a> »<br/> </li><li><a href=""><strong>The socket interface</strong></a></li></ul><hr></hr><em>ON THIS PAGE</em><ul><li><a href="#Usage and interface">Usage and interface</a></li><li><a href="#Documentation on exports">Documentation on exports</a></li><li><a href="#Documentation on imports">Documentation on imports</a></li></ul></div><div class="lpdoc-main"><div id=""><h1>The socket interface</h1><a class="lpdoc-idx-anchor" href="ciaosearch.html#sockets"></a>
<strong>Author(s):</strong> <a class="lpdoc-idx-anchor" id="Manuel Carro" href="ciaosearch.html#Manuel Carro">Manuel Carro</a>, <a class="lpdoc-idx-anchor" id="Daniel Cabeza" href="ciaosearch.html#Daniel Cabeza">Daniel Cabeza</a>.<p>
This module defines primitives to open sockets, send, and receive data from them. This allows communicating with other processes, on the same machine or across the Internet. The reader should also consult standard bibliography on the topic for a proper use of these primitives.<br/><div id="Usage and interface"><h2>Usage and interface</h2><div class="lpdoc-cartouche"><ul><li><strong>Library usage:</strong><br/><tt>:- use_module(library(sockets)).</tt><li><strong>Exports:</strong><br/><ul class="lpdoc-itemize-minus"><li><em>Predicates:</em><br/><a class="lpdoc-idx-anchor" id="0" href="#connect_to_socket_type/4"><tt>connect_to_socket_type/4</tt></a>, <a class="lpdoc-idx-anchor" id="1" href="#connect_to_socket/3"><tt>connect_to_socket/3</tt></a>, <a class="lpdoc-idx-anchor" id="2" href="#bind_socket/3"><tt>bind_socket/3</tt></a>, <a class="lpdoc-idx-anchor" id="3" href="#socket_accept/2"><tt>socket_accept/2</tt></a>, <a class="lpdoc-idx-anchor" id="4" href="#select_socket/5"><tt>select_socket/5</tt></a>, <a class="lpdoc-idx-anchor" id="5" href="#socket_send/3"><tt>socket_send/3</tt></a>, <a class="lpdoc-idx-anchor" id="6" href="#socket_sendall/2"><tt>socket_sendall/2</tt></a>, <a class="lpdoc-idx-anchor" id="7" href="#socket_send_stream/2"><tt>socket_send_stream/2</tt></a>, <a class="lpdoc-idx-anchor" id="8" href="#socket_recv/3"><tt>socket_recv/3</tt></a>, <a class="lpdoc-idx-anchor" id="9" href="#socket_shutdown/2"><tt>socket_shutdown/2</tt></a>, <a class="lpdoc-idx-anchor" id="10" href="#hostname_address/2"><tt>hostname_address/2</tt></a>, <a class="lpdoc-idx-anchor" id="11" href="#socket_getpeername/2"><tt>socket_getpeername/2</tt></a>.
<li><em>Regular Types:</em><br/><a class="lpdoc-idx-anchor" id="12" href="#socket_type/1"><tt>socket_type/1</tt></a>, <a class="lpdoc-idx-anchor" id="13" href="#shutdown_type/1"><tt>shutdown_type/1</tt></a>.
</ul></ul></div></div><div id="Documentation on exports"><h2>Documentation on exports</h2><div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="connect_to_socket_type/4" href="ciaosearch.html#connect_to_socket_type/4">connect_to_socket_type/4</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>connect_to_socket_type(Hostname,Port,Type,Stream)</tt>
</span><p>Returns a <span class="lpdoc-var">Stream</span> which connects to <span class="lpdoc-var">Hostname</span>. The <span class="lpdoc-var">Type</span> of connection can be defined. A <span class="lpdoc-var">Stream</span> is returned, which can be used to <a class="lpdoc-idx-anchor" id="14" href="iso_incomplete.html#write/2"><tt>write/2</tt></a> to, to <a class="lpdoc-idx-anchor" id="15" href="iso_incomplete.html#read/2"><tt>read/2</tt></a>, to <a class="lpdoc-idx-anchor" id="16" href="#socket_send/3"><tt>socket_send/3</tt></a> to, or to <a class="lpdoc-idx-anchor" id="17" href="#socket_recv/3"><tt>socket_recv/3</tt></a> from the socket.</p><ul class="lpdoc-itemize-minus"><li><em>Calls should, and exit will be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="18" href="term_typing.html#atom/1"><tt>term_typing:atom/1</tt></a>)</span><span><span class="lpdoc-var">Hostname</span> is currently instantiated to an atom.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="19" href="basic_props.html#int/1"><tt>basic_props:int/1</tt></a>)</span><span><span class="lpdoc-var">Port</span> is an integer.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="20" href="#socket_type/1"><tt>sockets:socket_type/1</tt></a>)</span><span><span class="lpdoc-var">Type</span> is a valid socket type.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="21" href="stream_basic.html#stream/1"><tt>stream_basic:stream/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is an open stream.
</span>
<li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="22" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Hostname</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="23" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Port</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="24" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Type</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="25" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is a free variable.
</span>
<li><em>The following properties hold globally:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="27" href="foreign_interface_properties.html#foreign_low/2"><tt>foreign_interface_properties:foreign_low/2</tt></a>)</span><span>The Prolog predicate <a class="lpdoc-idx-anchor" id="26" href="ciaosearch.html#PrologName"><tt>PrologName</tt></a> is implemented using the function <tt>ForeignName</tt>. The same considerations as above example are to be applied.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="connect_to_socket/3" href="ciaosearch.html#connect_to_socket/3">connect_to_socket/3</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>connect_to_socket(Hostname,Port,Stream)</tt>
</span><p>Calls <a class="lpdoc-idx-anchor" id="28" href="#connect_to_socket_type/4"><tt>connect_to_socket_type/4</tt></a> with SOCK_STREAM connection type. This is the connection type you want in order to use the <a class="lpdoc-idx-anchor" id="29" href="iso_incomplete.html#write/2"><tt>write/2</tt></a> and <a class="lpdoc-idx-anchor" id="30" href="iso_incomplete.html#read/2"><tt>read/2</tt></a> predicates (and other stream IO related predicates).</p><ul class="lpdoc-itemize-minus"><li><em>Call and exit should be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="31" href="basic_props.html#atm/1"><tt>basic_props:atm/1</tt></a>)</span><span><span class="lpdoc-var">Hostname</span> is an atom.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="32" href="basic_props.html#int/1"><tt>basic_props:int/1</tt></a>)</span><span><span class="lpdoc-var">Port</span> is an integer.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="33" href="stream_basic.html#stream/1"><tt>stream_basic:stream/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is an open stream.
</span>
<li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="34" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Hostname</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="35" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Port</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="36" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is a free variable.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="bind_socket/3" href="ciaosearch.html#bind_socket/3">bind_socket/3</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>bind_socket(Port,Length,Socket)</tt>
</span><p>Returns an AF_INET <span class="lpdoc-var">Socket</span> bound to <span class="lpdoc-var">Port</span> (which may be assigned by the OS or defined by the caller), and listens to it (hence no listen call in this set of primitives). <span class="lpdoc-var">Length</span> specifies the maximum number of pending connections.</p><ul class="lpdoc-itemize-minus"><li><em>Calls should, and exit will be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="37" href="basic_props.html#int/1"><tt>basic_props:int/1</tt></a>)</span><span><span class="lpdoc-var">Port</span> is an integer.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="38" href="basic_props.html#int/1"><tt>basic_props:int/1</tt></a>)</span><span><span class="lpdoc-var">Length</span> is an integer.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="39" href="basic_props.html#int/1"><tt>basic_props:int/1</tt></a>)</span><span><span class="lpdoc-var">Socket</span> is an integer.
</span>
<li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="40" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Length</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="41" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Socket</span> is a free variable.
</span>
<li><em>The following properties hold globally:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="43" href="foreign_interface_properties.html#foreign_low/2"><tt>foreign_interface_properties:foreign_low/2</tt></a>)</span><span>The Prolog predicate <a class="lpdoc-idx-anchor" id="42" href="ciaosearch.html#PrologName"><tt>PrologName</tt></a> is implemented using the function <tt>ForeignName</tt>. The same considerations as above example are to be applied.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="socket_accept/2" href="ciaosearch.html#socket_accept/2">socket_accept/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>socket_accept(Sock,Stream)</tt>
</span><p>Creates a new <span class="lpdoc-var">Stream</span> connected to <span class="lpdoc-var">Sock</span>.</p><ul class="lpdoc-itemize-minus"><li><em>Calls should, and exit will be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="44" href="basic_props.html#int/1"><tt>basic_props:int/1</tt></a>)</span><span><span class="lpdoc-var">Sock</span> is an integer.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="45" href="stream_basic.html#stream/1"><tt>stream_basic:stream/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is an open stream.
</span>
<li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="46" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Sock</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="47" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is a free variable.
</span>
<li><em>The following properties hold globally:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="49" href="foreign_interface_properties.html#foreign_low/2"><tt>foreign_interface_properties:foreign_low/2</tt></a>)</span><span>The Prolog predicate <a class="lpdoc-idx-anchor" id="48" href="ciaosearch.html#PrologName"><tt>PrologName</tt></a> is implemented using the function <tt>ForeignName</tt>. The same considerations as above example are to be applied.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="select_socket/5" href="ciaosearch.html#select_socket/5">select_socket/5</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>select_socket(Socket,NewStream,TO_ms,Streams,ReadStreams)</tt>
</span><p>Wait for data available in a list of <span class="lpdoc-var">Streams</span> and in a <span class="lpdoc-var">Socket</span>. <span class="lpdoc-var">Streams</span> is a list of Prolog streams which will be tested for reading. <span class="lpdoc-var">Socket</span> is a socket (i.e., an integer denoting the O.S. port number) or a <a class="lpdoc-idx-anchor" id="50" href="ciaosearch.html#free variable">free variable</a>. <span class="lpdoc-var">TO_ms</span> is a number denoting a timeout. Within this timeout the <span class="lpdoc-var">Streams</span> and the <span class="lpdoc-var">Socket</span> are checked for the availability of data to be read. <span class="lpdoc-var">ReadStreams</span> is the list of streams belonging to <span class="lpdoc-var">Streams</span> which have data pending to be read. If <span class="lpdoc-var">Socket</span> was a free variable, it is ignored, and <span class="lpdoc-var">NewStream</span> is not checked. If <span class="lpdoc-var">Socket</span> was instantiated to a port number and there are connections pending, a connection is accepted and connected with the Prolog stream in <span class="lpdoc-var">NewStream</span>.</p><ul class="lpdoc-itemize-minus"><li><em>Calls should, and exit will be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="51" href="basic_props.html#int/1"><tt>basic_props:int/1</tt></a>)</span><span><span class="lpdoc-var">Socket</span> is an integer.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="52" href="stream_basic.html#stream/1"><tt>stream_basic:stream/1</tt></a>)</span><span><span class="lpdoc-var">NewStream</span> is an open stream.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="53" href="basic_props.html#int/1"><tt>basic_props:int/1</tt></a>)</span><span><span class="lpdoc-var">TO_ms</span> is an integer.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="54" href="basic_props.html#list/2"><tt>basic_props:list/2</tt></a>)</span><span><span class="lpdoc-var">Streams</span> is a list of <span class="lpdoc-var">stream</span>s.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="55" href="basic_props.html#list/2"><tt>basic_props:list/2</tt></a>)</span><span><span class="lpdoc-var">ReadStreams</span> is a list of <span class="lpdoc-var">stream</span>s.
</span>
<li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="56" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Socket</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="57" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">NewStream</span> is a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="58" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">TO_ms</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="59" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Streams</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="60" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">ReadStreams</span> is a free variable.
</span>
<li><em>The following properties hold globally:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="62" href="foreign_interface_properties.html#foreign_low/2"><tt>foreign_interface_properties:foreign_low/2</tt></a>)</span><span>The Prolog predicate <a class="lpdoc-idx-anchor" id="61" href="ciaosearch.html#PrologName"><tt>PrologName</tt></a> is implemented using the function <tt>ForeignName</tt>. The same considerations as above example are to be applied.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="socket_send/3" href="ciaosearch.html#socket_send/3">socket_send/3</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>socket_send(Stream,Bytes,Sent)</tt>
</span><p>Sends <span class="lpdoc-var">Bytes</span> to the socket associated to <span class="lpdoc-var">Stream</span>, return in <span class="lpdoc-var">Sent</span> the number of sent bytes. The socket has to be in connected state.</p><ul class="lpdoc-itemize-minus"><li><em>Calls should, and exit will be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="63" href="stream_basic.html#stream/1"><tt>stream_basic:stream/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is an open stream.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="64" href="basic_props.html#bytelist/1"><tt>basic_props:bytelist/1</tt></a>)</span><span><span class="lpdoc-var">Bytes</span> is list of bytes.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="65" href="basic_props.html#int/1"><tt>basic_props:int/1</tt></a>)</span><span><span class="lpdoc-var">Sent</span> is an integer.
</span>
<li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="66" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="67" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Bytes</span> is currently a term which is not a free variable.
</span>
<li><em>The following properties hold globally:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="69" href="foreign_interface_properties.html#foreign_low/2"><tt>foreign_interface_properties:foreign_low/2</tt></a>)</span><span>The Prolog predicate <a class="lpdoc-idx-anchor" id="68" href="ciaosearch.html#PrologName"><tt>PrologName</tt></a> is implemented using the function <tt>ForeignName</tt>. The same considerations as above example are to be applied.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="socket_sendall/2" href="ciaosearch.html#socket_sendall/2">socket_sendall/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>socket_sendall(Stream,Bytes)</tt>
</span><p>Sends all <span class="lpdoc-var">Bytes</span> to the socket associated to <span class="lpdoc-var">Stream</span>. The socket has to be in connected state.</p><ul class="lpdoc-itemize-minus"><li><em>Calls should, and exit will be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="70" href="stream_basic.html#stream/1"><tt>stream_basic:stream/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is an open stream.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="71" href="basic_props.html#bytelist/1"><tt>basic_props:bytelist/1</tt></a>)</span><span><span class="lpdoc-var">Bytes</span> is list of bytes.
</span>
<li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="72" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="73" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Bytes</span> is currently a term which is not a free variable.
</span>
<li><em>The following properties hold globally:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="75" href="foreign_interface_properties.html#foreign_low/2"><tt>foreign_interface_properties:foreign_low/2</tt></a>)</span><span>The Prolog predicate <a class="lpdoc-idx-anchor" id="74" href="ciaosearch.html#PrologName"><tt>PrologName</tt></a> is implemented using the function <tt>ForeignName</tt>. The same considerations as above example are to be applied.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="socket_send_stream/2" href="ciaosearch.html#socket_send_stream/2">socket_send_stream/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>socket_send_stream(Stream,FromStream)</tt>
</span><p>Sends all bytes from stream <span class="lpdoc-var">FromStream</span> to the socket associated to <span class="lpdoc-var">Stream</span>. The socket has to be in connected state. <span class="lpdoc-var">FromStream</span> cannot be a socket stream</p><ul class="lpdoc-itemize-minus"><li><em>Calls should, and exit will be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="76" href="stream_basic.html#stream/1"><tt>stream_basic:stream/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is an open stream.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="77" href="stream_basic.html#stream/1"><tt>stream_basic:stream/1</tt></a>)</span><span><span class="lpdoc-var">FromStream</span> is an open stream.
</span>
<li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="78" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="79" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">FromStream</span> is currently a term which is not a free variable.
</span>
<li><em>The following properties hold globally:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="81" href="foreign_interface_properties.html#foreign_low/2"><tt>foreign_interface_properties:foreign_low/2</tt></a>)</span><span>The Prolog predicate <a class="lpdoc-idx-anchor" id="80" href="ciaosearch.html#PrologName"><tt>PrologName</tt></a> is implemented using the function <tt>ForeignName</tt>. The same considerations as above example are to be applied.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="socket_recv/3" href="ciaosearch.html#socket_recv/3">socket_recv/3</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>socket_recv(Stream,Bytes,Length)</tt>
</span><p>Receives a byte list <span class="lpdoc-var">Bytes</span> from the socket associated to <span class="lpdoc-var">Stream</span>, and returns its <span class="lpdoc-var">Length</span>. For TCP, <span class="lpdoc-var">Length</span> is 0 if the peer has performed an orderly shutdown on the socket.</p><ul class="lpdoc-itemize-minus"><li><em>Calls should, and exit will be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="82" href="stream_basic.html#stream/1"><tt>stream_basic:stream/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is an open stream.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="83" href="basic_props.html#bytelist/1"><tt>basic_props:bytelist/1</tt></a>)</span><span><span class="lpdoc-var">Bytes</span> is list of bytes.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="84" href="basic_props.html#int/1"><tt>basic_props:int/1</tt></a>)</span><span><span class="lpdoc-var">Length</span> is an integer.
</span>
<li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="85" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is currently a term which is not a free variable.
</span>
<li><em>The following properties hold globally:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="87" href="foreign_interface_properties.html#foreign_low/2"><tt>foreign_interface_properties:foreign_low/2</tt></a>)</span><span>The Prolog predicate <a class="lpdoc-idx-anchor" id="86" href="ciaosearch.html#PrologName"><tt>PrologName</tt></a> is implemented using the function <tt>ForeignName</tt>. The same considerations as above example are to be applied.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="socket_shutdown/2" href="ciaosearch.html#socket_shutdown/2">socket_shutdown/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>socket_shutdown(Stream,How)</tt>
</span><p>Shut down a duplex communication socket with which <span class="lpdoc-var">Stream</span> is associated. All or part of the communication can be shutdown, depending on the value of <span class="lpdoc-var">How</span>. The atoms <tt>read</tt>, <tt>write</tt>, or <span class="lpdoc-var">read_write</span> should be used to denote the type of closing required.</p><ul class="lpdoc-itemize-minus"><li><em>Calls should, and exit will be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="88" href="stream_basic.html#stream/1"><tt>stream_basic:stream/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is an open stream.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="89" href="#shutdown_type/1"><tt>sockets:shutdown_type/1</tt></a>)</span><span><span class="lpdoc-var">How</span> is a valid shutdown type.
</span>
<li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="90" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="91" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">How</span> is currently a term which is not a free variable.
</span>
<li><em>The following properties hold globally:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="93" href="foreign_interface_properties.html#foreign_low/2"><tt>foreign_interface_properties:foreign_low/2</tt></a>)</span><span>The Prolog predicate <a class="lpdoc-idx-anchor" id="92" href="ciaosearch.html#PrologName"><tt>PrologName</tt></a> is implemented using the function <tt>ForeignName</tt>. The same considerations as above example are to be applied.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="hostname_address/2" href="ciaosearch.html#hostname_address/2">hostname_address/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>hostname_address(Hostname,Address)</tt>
</span><p><span class="lpdoc-var">Address</span> is unified with the atom representing the address (in AF_INET format) corresponding to <span class="lpdoc-var">Hostname</span>.</p><ul class="lpdoc-itemize-minus"><li><em>Calls should, and exit will be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="94" href="basic_props.html#atm/1"><tt>basic_props:atm/1</tt></a>)</span><span><span class="lpdoc-var">Hostname</span> is an atom.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="95" href="basic_props.html#atm/1"><tt>basic_props:atm/1</tt></a>)</span><span><span class="lpdoc-var">Address</span> is an atom.
</span>
<li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="96" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Hostname</span> is currently a term which is not a free variable.
</span>
<li><em>The following properties hold globally:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="98" href="foreign_interface_properties.html#foreign_low/2"><tt>foreign_interface_properties:foreign_low/2</tt></a>)</span><span>The Prolog predicate <a class="lpdoc-idx-anchor" id="97" href="ciaosearch.html#PrologName"><tt>PrologName</tt></a> is implemented using the function <tt>ForeignName</tt>. The same considerations as above example are to be applied.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="socket_getpeername/2" href="ciaosearch.html#socket_getpeername/2">socket_getpeername/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>socket_getpeername(Stream,Address)</tt>
</span><p><span class="lpdoc-var">Address</span> is unified with the atom representing the address (in AF_INET or AF_INET6 format) of the peer connected to the socket associated to <span class="lpdoc-var">Stream</span>.</p><ul class="lpdoc-itemize-minus"><li><em>Calls should, and exit will be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="99" href="stream_basic.html#stream/1"><tt>stream_basic:stream/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is an open stream.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="100" href="basic_props.html#atm/1"><tt>basic_props:atm/1</tt></a>)</span><span><span class="lpdoc-var">Address</span> is an atom.
</span>
<li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="101" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Stream</span> is currently a term which is not a free variable.
</span>
<li><em>The following properties hold globally:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="103" href="foreign_interface_properties.html#foreign_low/2"><tt>foreign_interface_properties:foreign_low/2</tt></a>)</span><span>The Prolog predicate <a class="lpdoc-idx-anchor" id="102" href="ciaosearch.html#PrologName"><tt>PrologName</tt></a> is implemented using the function <tt>ForeignName</tt>. The same considerations as above example are to be applied.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="socket_type/1" href="ciaosearch.html#socket_type/1">socket_type/1</a></div><div class="lpdoc-deftext">Defines the atoms which can be used to specify the socket type recognized by <a class="lpdoc-idx-anchor" id="104" href="#connect_to_socket_type/4"><tt>connect_to_socket_type/4</tt></a>. Defined as follows: <pre class="lpdoc-codeblock">socket_type(stream).
socket_type(dgram).
socket_type(raw).
socket_type(seqpacket).
socket_type(rdm).
</pre><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>socket_type(T)</tt>
</span><p><span class="lpdoc-var">T</span> is a valid socket type.</p><ul class="lpdoc-itemize-minus"></ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="shutdown_type/1" href="ciaosearch.html#shutdown_type/1">shutdown_type/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>shutdown_type(T)</tt>
</span><p><span class="lpdoc-var">T</span> is a valid shutdown type.</p><ul class="lpdoc-itemize-minus"></ul></div></div><p>
</div><div id="Documentation on imports"><h2>Documentation on imports</h2>This module has the following direct dependencies:<ul class="lpdoc-itemize-minus"><li><em>System library modules:</em><br/><a class="lpdoc-idx-anchor" id="105" href="foreign_interface_properties.html"><tt>foreign_interface_properties</tt></a>.
<li><em>Packages:</em><br/><a class="lpdoc-idx-anchor" id="106" href="ciaosearch.html#prelude"><tt>prelude</tt></a>, <a class="lpdoc-idx-anchor" id="107" href="ciaosearch.html#initial"><tt>initial</tt></a>, <a class="lpdoc-idx-anchor" id="108" href="condcomp_doc.html"><tt>condcomp</tt></a>, <a class="lpdoc-idx-anchor" id="109" href="assertions_doc.html"><tt>assertions</tt></a>, <a class="lpdoc-idx-anchor" id="110" href="ciaosearch.html#assertions/assertions_basic"><tt>assertions/assertions_basic</tt></a>, <a class="lpdoc-idx-anchor" id="111" href="isomodes_doc.html"><tt>isomodes</tt></a>, <a class="lpdoc-idx-anchor" id="112" href="regtypes_doc.html"><tt>regtypes</tt></a>, <a class="lpdoc-idx-anchor" id="113" href="foreign_interface_doc.html"><tt>foreign_interface</tt></a>, <a class="lpdoc-idx-anchor" id="114" href="basicmodes_doc.html"><tt>basicmodes</tt></a>, <a class="lpdoc-idx-anchor" id="115" href="ciaosearch.html#engine(foreign_types)"><tt>engine(foreign_types)</tt></a>.
</ul></div></div><div class="lpdoc-footer">Generated with LPdoc using Ciao</div></div><div class="lpdoc-clearer"></div></div></body></html>