On this page:
Zero  MQ
context?
socket?
socket-type?
option-name?
send/  recv-flags?
poll-status?
zmq-version
msg?
_  msg
poll-item?
make-poll-item
poll-item-revents
context
context-close!
call-with-context
msg-init!
msg-init-size!
msg-close!
msg-data-pointer
msg-size
msg-data
make-empty-msg
make-msg-with-data
make-msg-with-size
msg-copy!
msg-move!
socket
socket-close!
call-with-socket
socket-option
set-socket-option!
socket-bind!
socket-connect!
socket-send-msg!
socket-send!
socket-recv-msg!
socket-recv!
poll!
proxy!
7.0

ZeroMQ

Jay McCarthy <[email protected]>

 (require net/zmq) package: zeromq

This package provides a binding for the ZeroMQ library.

This documentation does not describe meaning of API calls; it only describes their Racket calling conventions. For details on API semantics, refer to the documentation at the ZeroMQ site.

zmq_msg_init_data is not supported, because Racket pointers may be moved by the garbage collector before the ZeroMQ library is done with them.

procedure

(context? x)  boolean?

  x : any/c
Determines if x is a pointer to a ZeroMQ context.

procedure

(socket? x)  boolean?

  x : any/c
Determines if x is a pointer to a ZeroMQ socket.
A contract for the symbols '(PAIR PUB SUB REQ REP DEALER ROUTER XREQ XREP PULL PUSH XPUB XSUB STREAM)
A contract for the symbols '(AFFINITY IDENTITY SUBSCRIBE UNSUBSCRIBE RATE RECOVERY_IVL SNDBUF RCVBUF RCVMORE FD EVENTS TYPE LINGER RECONNECT_IVL BACKLOG RECONNECT_IVL_MAX MAXMSGSIZE SNDHWM RCVHWM MULTICAST_HOPS RCVTIMEO SNDTIMEO LAST_ENDPOINT ROUTER_MANDATORY TCP_KEEPALIVE TCP_KEEPALIVE_CNT TCP_KEEPALIVE_IDLE TCP_KEEPALIVE_INTVL IMMEDIATE XPUB_VERBOSE ROUTER_RAW IPV6 MECHANISM PLAIN_SERVER PLAIN_USERNAME PLAIN_PASSWORD CURVE_SERVER CURVE_PUBLICKEY CURVE_SECRETKEY CURVE_SERVERKEY PROBE_ROUTER REQ_CORRELATE REQ_RELAXED CONFLATE ZAP_DOMAIN ROUTER_HANDOVER TOS CONNECT_RID GSSAPI_SERVER GSSAPI_PRINCIPAL GSSAPI_SERVICE_PRINCIPAL GSSAPI_PLAINTEXT HANDSHAKE_IVL SOCKS_PROXY XPUB_NODROP BLOCKY XPUB_MANUAL XPUB_WELCOME_MSG STREAM_NOTIFY INVERT_MATCHING HEARTBEAT_IVL HEARTBEAT_TTL HEARTBEAT_TIMEOUT XPUB_VERBOSER CONNECT_TIMEOUT TCP_MAXRT THREAD_SAFE MULTICAST_MAXTPDU VMCI_BUFFER_SIZE VMCI_BUFFER_MIN_SIZE VMCI_BUFFER_MAX_SIZE VMCI_CONNECT_TIMEOUT USE_FD)
A contract for any symbol in '(DONTWAIT NOBLOCK SNDMORE) or any list of those symbols.
A contract for any symbol in '(POLLIN POLLOUT POLLERR) or any list of those symbols.
An FFI binding for zmq_version.

procedure

(msg? x)  boolean?

  x : any/c
Determines if x is a ZeroMQ message.

value

_msg : ctype?

A ctype for ZeroMQ messages, suitable for using with malloc.

procedure

(poll-item? x)  boolean?

  x : any/c
Determines if x is a ZeroMQ poll item.

procedure

(make-poll-item socket fd events revents)  poll-item?

  socket : socket?
  fd : exact-nonnegative-integer?
  events : poll-status?
  revents : poll-status?
Constructs a poll item for using with poll!.

procedure

(poll-item-revents pi)  poll-status?

  pi : poll-item?
Extracts the revents field from a poll item structure.

procedure

(context io_threads)  context?

  io_threads : exact-nonnegative-integer?
An FFI binding for zmq_init.

procedure

(context-close! context)  void

  context : context?
An FFI binding for zmq_term.

procedure

(call-with-context procedure    
  [#:io-threads io-threads])  void
  procedure : (procedure-arity-includes/c 1)
  io-threads : exact-nonnegative-integer? = 1
Using the context procedure, call-with-context creates a context and passes it to a procedure with one argument. On return, it closes the context using context-close!

procedure

(msg-init! msg)  void

  msg : msg?
An FFI binding for zmq_msg_init.

procedure

(msg-init-size! msg size)  void

  msg : msg?
  size : exact-nonnegative-integer?
An FFI binding for zmq_msg_init_size.

procedure

(msg-close! msg)  void

  msg : msg?
An FFI binding for zmq_msg_close.

procedure

(msg-data-pointer msg)  cpointer?

  msg : msg?
An FFI binding for zmq_msg_data.

procedure

(msg-size msg)  exact-nonnegative-integer?

  msg : msg?
An FFI binding for zmq_msg_size.

procedure

(msg-data msg)  bytes?

  msg : msg?
Creates a sized byte string from a message’s data.

procedure

(make-empty-msg)  msg?

Returns a _msg ctype with no data. The _msg must be manually deallocated using free

procedure

(make-msg-with-data bytes)  msg?

  bytes : bytes?
Returns a _msg ctype whose msg-data is set to given the byte string. The _msg must be manually deallocated using free

procedure

(make-msg-with-size exact-nonnegative-integer)  msg?

  exact-nonnegative-integer : exact-nonnegative-integer?
Returns a _msg ctype whose size is set the given non-negative integer. The _msg must be manually deallocated using free

procedure

(msg-copy! dest src)  void

  dest : msg?
  src : msg?
An FFI binding for zmq_msg_copy.

procedure

(msg-move! dest src)  void

  dest : msg?
  src : msg?
An FFI binding for zmq_msg_move.

procedure

(socket ctxt type)  socket?

  ctxt : context?
  type : socket-type?
An FFI binding for zmq_socket.

procedure

(socket-close! socket)  void

  socket : socket?
An FFI binding for zmq_close.

procedure

(call-with-socket context    
  socket-type    
  procedure)  void
  context : context?
  socket-type : socket-type?
  procedure : (procedure-arity-includes/c 1)
Using the socket procedure, call-with-socket creates a socket of a valid socket-type? using a previously created context. It passes the socket to a procedure with one argument. On return, it closes the socket using socket-close!

procedure

(socket-option socket option-name)

  
(or/c
 
 
 
 
 
 
boolean?
 
exact-integer?
 
exact-nonnegative-integer?                 bytes?)
  socket : socket?
  option-name : option-name?
Extracts the given option’s value from the socket, similar to zmq_getsockopt.

procedure

(set-socket-option! socket    
  option-name    
  option-value)  void
  socket : socket?
  option-name : option-name?
  option-value : 
(or/c
 
 
 
 
 
 
exact-nonnegative-integer?
 
exact-integer?
 
boolean?                                                     bytes?)
Sets the given option’s value from the socket, similar to zmq_setsockopt.

procedure

(socket-bind! socket endpoint)  void

  socket : socket?
  endpoint : string?
An FFI binding for zmq_bind.

procedure

(socket-connect! socket endpoint)  void

  socket : socket?
  endpoint : string?
An FFI binding for zmq_connect.

procedure

(socket-send-msg! msg socket flags)  exact-integer?

  msg : msg?
  socket : socket?
  flags : send/recv-flags?
An FFI binding for zmq_msg_send.

procedure

(socket-send! socket bytes)  void

  socket : socket?
  bytes : bytes?
Sends a byte string on a socket using socket-send-msg! and a temporary message.

procedure

(socket-recv-msg! msg socket flags)  void

  msg : msg?
  socket : socket?
  flags : send/recv-flags?
An FFI binding for zmq_msg_recv.

procedure

(socket-recv! socket)  bytes?

  socket : socket?
Receives a byte string on a socket using socket-recv-msg! and a temporary message.

procedure

(poll! items timeout)  void

  items : (vectorof poll-item?)
  timeout : exact-integer?
An FFI binding for zmq_poll.

procedure

(proxy! frontend backend [capture])  void

  frontend : socket?
  backend : socket?
  capture : (or/c socket? false?) = #f
An FFI binding for zmq_proxy. Given two sockets and an optional capture socket, set up a proxy between the frontend socket and the backend socket.