File: iter_try.r

package info (click to toggle)
r-cran-pbdzmq 0.3.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 800 kB
  • sloc: ansic: 675; sh: 93; pascal: 30; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 558 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
### Iterative pollers
# SHELL> Rscript iter_try.r

library(pbdZMQ, quietly = TRUE)

### Initial.
context <- zmq.ctx.new()
receiver <- zmq.socket(context, .pbd_env$ZMQ.ST$PULL)
zmq.connect(receiver, "tcp://localhost:5557")

### Process messages from the socket.
for(i in 1:5){
  cat("Press Ctrl+C or Esc to stop iter_script ... ", i, "\n", sep = "")
  aa <- tryCatch(zmq.poll2.interrupt(c(receiver), c(.pbd_env$ZMQ.PO$POLLIN)),
                 interrupt = function(c){ c$ret$pollret })
  print(aa)
}

### Finish.
zmq.close(receiver)
zmq.ctx.destroy(context)