(import (network nanomsg))
Bindings to the nanomsg network library.
(make-nanomsg-condition message errno)
The &nanomsg condition type is derived from &message and stores an error code together with the message.
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.
Checks whether the given value is a nanomsg socket.
(open-socket domain protocol)
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 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.
(socket-option socket level option)
Retrieves socket option data. The option is identified by the level and option symbols. The value is returned as a bytevector.
(socket-option-set! socket level option v)
Sets a socket option. The option is identified by the level and option symbols. The values is specified as a bytevector.
(socket-bind socket address)
Binds the socket to the local address specified as a string. Returns a numeric endpoint identifier.
(socket-connect socket address)
Connects the socket to the remote address specified as a string. Returns a numeric endpoint identifier.
(socket-shutdown socket id)
Closes the specified endpoint of the socket.
(socket-send socket message option ...)
Sends a bytevector through the socket. Option symbols may be passed to modify the behaviour of the operation.
(socket-receive socket length option ...)
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.
(socket-events symbol ...)
The socket event enumeration has the members in and out.
(socket-poll ((socket symbol ...) ...) timeout)
(socket-poll ((socket . events) ...) timeout)
(socket-poll #((socket symbol ...) ...) timeout)
(socket-poll #((socket . events) ...) timeout)
Polls the given sockets for the specified events. Event sets may be specified as lists of symbols (in or out) 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.