zmqc: 0MQ PUB-SUB connection

Description Usage Arguments Details Value Author(s) Examples

View source: R/zmqc.R

Description

zmqc creates a 0MQ PUB/SUB connection. Modes beginning with "w" and "a" are equivalent and create a PUB connection while modes beginning with "r" create a SUB connection.

Usage

1
  zmqc(endpoint, mode = "")

Arguments

endpoint

string defining the 0MQ endpoint of the connection consisting of <transport>://<address>. See 0MQ documentation for details, but most common transports are tcp, ipc, inproc, pgm and epgm.

mode

see Modes section in connections documentation and below.

Details

mode set to "r" or "rb" opens a SUB connection and it is read-only by design. mode set to "w" or "wb" creates a PUB connection which is write-only by design. The modes "a" and "ab" are equivalent to "w" and "wb" respectively. No other modes are supported.

Value

zmqc connection

Author(s)

Simon Urbanek

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
  pub <- zmqc("ipc:///tmp/0mq.sock", "w")
  sub <- zmqc("ipc:///tmp/0mq.sock", "r")
  ## subscriptions make take a bit to setup so
  ## we add a small delay to make sure the subscriber
  ## is ready
  Sys.sleep(1)
  writeLines("hello, world!", pub)
  writeLines("I'm publishing ...", pub)
  readLines(sub, 1)
  close(sub)
  close(pub)
  ## clean up the socket since we won't be re-using it
  ## if you plan to re-use the socket, it is actually
  ## possble to keep it to allow subscriptions before
  ## the publisher is started
  unlink("/tmp/0mq.sock")

s-u/zmqc documentation built on May 28, 2019, 10:49 a.m.

Related to zmqc in s-u/zmqc...