chez-libs

Artifact [6d561fd8e8]
Login

Artifact 6d561fd8e88045ef64624795aaacb1d4d160494f:

Wiki page [(network nanomsg)] by murphy 2016-06-02 09:23:46.
D 2016-06-02T09:23:46.618
L (network\snanomsg)
P b1b08e35decc9121da08b5ef9ea70e6146066d84
U murphy
W 3899
<h1>nanomsg Bindings</h1>

<h2>Synopsis</h2>

<code>(import (network nanomsg))</code>

Bindings to the [http://nanomsg.org/|nanomsg] network library.

<h2>Conditions</h2>

<h3>condition: <code>&nanomsg</code></h3>
<h3>procedure: <code>(nanomsg-condition? <i>any</i>)</code></h3>
<h3>procedure: <code>(make-nanomsg-condition <i>message</i> <i>errno</i>)</code></h3>
<h3>procedure: <code>(nanomsg-condition-errno <i>condition</i>)</code></h3>

The <tt>&nanomsg</tt> condition type is derived from <tt>&message</tt> and stores an error code together with the message.

<h2>Operations</h2>

<h3>procedure: <code>(nanomsg-constant <i>symbol</i>)</code></h3>

Retrieves the integer value associated by nanomsg with a given symbol. Naming convention is lower case with hyphens, as usual for Scheme, unlike the upper case with underscores convention used in C.

<h3>procedure: <code>(socket? <i>v</i>)</code></h3>

Checks whether the given value is a nanomsg socket.

<h3>procedure: <code>(open-socket <i>domain</i> <i>protocol</i>)</code></h3>

Creates a new nanomsg socket given symbols that identify the protocol to use. At some point in the future, the socket should be closed using <tt>close-socket</tt>.

<h3>procedure: <code>(close-socket <i>socket</i>)</code></h3>

Closes the given socket. It does not hurt to call this procedure more than once on the same socket, but once it has been applied to a socket, it becomes unusable.

<h3>procedure: <code>(socket-option <i>socket</i> <i>level</i> <i>option</i>)</code></h3>

Retrieves socket option data. The option is identified by the level and option symbols. The value is returned as a bytevector.

<h3>procedure: <code>(socket-option-set! <i>socket</i> <i>level</i> <i>option</i> <i>v</i>)</code></h3>

Sets a socket option. The option is identified by the level and option symbols. The values is specified as a bytevector.

<h3>procedure: <code>(socket-bind <i>socket</i> <i>address</i>)</code></h3>

Binds the socket to the local address specified as a string. Returns a numeric endpoint identifier.

<h3>procedure: <code>(socket-connect <i>socket</i> <i>address</i>)</code></h3>

Connects the socket to the remote address specified as a string. Returns a numeric endpoint identifier.

<h3>procedure: <code>(socket-shutdown <i>socket</i> <i>id</i>)</code></h3>

Closes the specified endpoint of the socket.

<h3>procedure: <code>(socket-send <i>socket</i> <i>message</i> <i>option</i> ...)</code></h3>

Sends a bytevector through the socket. Option symbols may be passed to modify the behaviour of the operation.

<h3>procedure: <code>(socket-receive <i>socket</i> <i>length</i> <i>option</i> ...)</code></h3>

Receives a bytevector through the socket. The maximum length of the message must be specified. Option symbols may be passed to modify the behaviour of the operation.

<h3>syntax: <code>(socket-event <i>symbol</i>)</code></h3>
<h3>syntax: <code>(socket-events <i>symbol</i> ...)</code></h3>

The socket event enumeration has the members <tt>in</tt> and <tt>out</tt>.

<h3>procedure: <code>(socket-poll ((<i>socket</i> <i>symbol</i> ...) ...) <i>timeout</i>)</code></h3>
<h3>procedure: <code>(socket-poll ((<i>socket</i> . <i>events</i>) ...) <i>timeout</i>)</code></h3>
<h3>procedure: <code>(socket-poll #((<i>socket</i> <i>symbol</i> ...) ...) <i>timeout</i>)</code></h3>
<h3>procedure: <code>(socket-poll #((<i>socket</i> . <i>events</i>) ...) <i>timeout</i>)</code></h3>

Polls the given sockets for the specified events. Event sets may be specified as lists of symbols (<tt>in</tt> or <tt>out</tt>) or as enumeration sets.

Returns a list of pairs of sockets and event enumeration sets. The result contains an elements for every socket for which the resulting event set is not empty.

The timeout is specified in seconds but has millisecond granularity.

Z fb1ae4d4103719f76c64540581d0f0fb