Debian Codegraph @

demo/hwserver.r

raw symbols SCIP
1 ### Hello world server as in the ZeroMQ guide.
2 # SHELL> Rscript hwserver.r &
3 # SHELL> Rscript hwclient.r
4
5 suppressMessages(library(pbdZMQ, quietly = TRUE))
6
7 ### Initial.
8 context <- zmq.ctx.new()
9 responder <- zmq.socket(context, ZMQ.ST()$REP)
10 zmq.bind(responder, "tcp://*:5555")
11
12 ### Send and receive 5 times.
13 for(i.res in 1:5){
14 buf <- zmq.recv(responder, 10L)
15 cat(buf$buf, "\n")
16 Sys.sleep(0.5)
17 zmq.send(responder, "World")
18 }
19
20 ### Finish.
21 zmq.close(responder)
22 zmq.ctx.destroy(context)