Minimal Zero  MQ Bindings
Socket
Socket-Kind
socket?
socket-kind?
socket
socket-identity
socket-send
socket-receive
socket-receive-evt
socket-bind
socket-connect
socket-subscribe
socket-unsubscribe
8.12

Minimal ZeroMQ Bindings🔗ℹ

Jan Dvořák <mordae@anilinux.org>

 (require zmq) package: zmq

This module is typed and can be used from both normal and typed code.

syntax

Socket

Type of a ZeroMQ socket of any kind.

Type of a ZeroMQ socket kind, equivalent to (U 'router 'pub 'sub).

The 'router socket can send messages to any of it’s peers, always prefixed with that particular peer’s identity part. The other two kinds 'pub and 'sub can connect to each other and allow one-way distribution of messages without the need to identify individual recipients on the sender’s side.

procedure

(socket? v)  Boolean

  v : Any
Predicate for Socket.

procedure

(socket-kind? v)  Boolean

  v : Any
Predicate for Socket-Kind.

procedure

(socket kind    
  #:identity identity    
  #:subscribe subscribe    
  #:bind bind    
  #:connect connect    
  #:send-queue send-queue    
  #:receive-queue receive-queue)  Socket
  kind : Socket-Kind
  identity : (U String Bytes)
  subscribe : (Listof (U String Bytes))
  bind : (Listof String)
  connect : (Listof String)
  send-queue : Natural
  receive-queue : Natural
Create new socket of specified kind and optionally immediately bind and/or connect it, using defined identity.

The send-queue and receive-queue options correspond to ZeroMQ high-water marks. That is, number of packets to buffer when the peer is not available.

procedure

(socket-identity s)  Bytes

  s : Socket
(socket-identity s identity)  Void
  s : Socket
  identity : (U String Bytes)
Determine or change socket identity.

Changing the identity after connections have been established (via binding or connecting) will most likely not work as desired.

procedure

(socket-send s part ...)  Void

  s : Socket
  part : (U Bytes String)
Send a multi-part message.

When operating in the 'router mode, first part is reserved for target peer’s identity.

procedure

(socket-receive s)  (Listof Bytes)

  s : Socket
Receive a multi-part message as a list of it’s parts.

When operating in the 'router mode, first part is reserved for target peer’s identity.

procedure

(socket-receive-evt s)  (Evtof (Listof Bytes))

  s : Socket
Returns an asynchronous event that produces received lists. Results are identical to return values of socket-receive.

procedure

(socket-bind s addr)  Void

  s : Socket
  addr : String
Bind to specified ZeroMQ endpoint address such as "tcp://127.0.0.1:1234".

procedure

(socket-connect s addr)  Void

  s : Socket
  addr : String
Connect to specified ZeroMQ endpoint address such as "tcp://127.0.0.1:1234".

procedure

(socket-subscribe s prefix)  Void

  s : Socket
  prefix : (U String Bytes)
Used with 'sub sockets to define prefix of messages to receive from a peer 'pub socket.

procedure

(socket-unsubscribe s prefix)  Void

  s : Socket
  prefix : (U String Bytes)
Cancel subscription made with socket-subscribe.