ExpandCollapse

+ 1 rrserver.flx

  //
  //  Hello World server
  //  Connects REP socket to tcp://*:5560
  //  Expects "Hello" from client, replies with "World"
  //
  open ZMQ;
  include "std/io/faio";
  var sys_clock = #Faio::mk_alarm_clock;
  
  var context = zmq_init 1;
  
  //  Socket to talk to clients
  var responder = context.mk_socket ZMQ_REP;
  responder.connect "tcp://localhost:5560";
  
  while true do
    //  Wait for next request from client
    var s = responder.recv_string;
    println$ f"Received request: [%S]" s;
  
    //  Do some 'work'
    Faio::sleep (sys_clock,1.0e-3); // 1 ms
  
    //  Send reply back to client
    responder.send_string "World";
  done