static void Main(string[] args)
 {
     // allocate a buffer
     byte[] zmq_buffer = new byte[1024];
     //  Prepare our context and socket
     ZMQ.Context context = new ZMQ.Context(1);
     ZMQ.Socket  socket  = context.Socket(ZMQ.SocketType.REP);
     socket.Bind("tcp://*:5555");
     while (true)
     {
         try {
             //  Wait for next request from client
             zmq_buffer = socket.Recv();
             string request = Encoding.ASCII.GetString(zmq_buffer);
             // log that we got one
             Console.WriteLine("Received request: [%s]", request);
             //  Do some 'work'
             Thread.Sleep(1);
             //  Send reply back to client
             socket.Send(Encoding.ASCII.GetBytes("World".ToCharArray()));
         } catch (ZMQ.Exception z) {
             // report the exception
             Console.WriteLine("ZMQ Exception occurred : {0}", z.Message);
         }
     }
 }
Example #2
0
 static void Main(string[] args)
 {
     InitErrMessages();
     rep = cntx.Socket(ZMQ.SocketType.REP);
     rep.Bind("tcp://*:1000");
     pub = cntx.Socket(ZMQ.SocketType.PUB);
     pub.Bind("tcp://*:1001");
     while (true)
     {
         byte[] buf = rep.Recv(0);
         if (buf != null)
         {
             Process(buf);
         }
     }
 }
Example #3
0
 static void Main(string[] args)
 {
     InitErrMessages();
     rep = cntx.Socket(ZMQ.SocketType.REP);
     rep.Bind("tcp://*:1000");
     pub = cntx.Socket(ZMQ.SocketType.PUB);
     pub.Bind("tcp://*:1001");
     while (true)
     {
         byte[] buf = rep.Recv(0);
         if (buf != null)
         {
             Process(buf);
         }
     }
 }
Example #4
0
 public void Bind(String address)
 {
     _zmqSocket.Bind(address);
 }