private void _ServerThread() { while (this.isok) { try { using (var socket = new ResponseSocket(this.addr)) { // loop until told to stop or when exception is thrown while (this.isok) { // wait for 50 ms if (socket.Poll(PollEvents.PollIn, TimeSpan.FromMilliseconds(50)).HasIn()) { this._RecvAndSend(socket); } } } } catch (NetMQException e) { // recover from zmq error by re-creating socket // TODO: log here Console.WriteLine("Encountered ZMQ error: {0}, will re-create socket.", e.Message); } } }
private static void WorkerRoutine() { try { using (ResponseSocket rep = new ResponseSocket()) { rep.Options.Identity = Encoding.Unicode.GetBytes(Guid.NewGuid().ToString()); rep.Connect("tcp://localhost:5556"); //rep.Connect("inproc://workers"); rep.ReceiveReady += RepOnReceiveReady; while (!s_token.IsCancellationRequested) { rep.Poll(TimeSpan.FromMilliseconds(100)); } } } catch (Exception ex) { Console.WriteLine("Exception on WorkerRoutine: {0}", ex.Message); throw; } }