<h1>nanomsg Bindings</h1>

<h2>Synopsis</h2>

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

Bindings to the network library.

<h2>Conditions</h2>

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

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

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?

Checks whether the given value is a nanomsg socket.

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

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

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>

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>

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>

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

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

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

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

Closes the specified endpoint of the socket.

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

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>

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
<h3>syntax: <code>(socket-events <i>symbol</i>

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> ...) ...)
<h3>procedure: <code>(socket-poll ((<i>socket</i> . <i>events</i>) ...)
<h3>procedure: <code>(socket-poll #((<i>socket</i> <i>symbol</i> ...) ...)
<h3>procedure: <code>(socket-poll #((<i>socket</i> . <i>events</i>) ...)

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.