static void Main(string[] args) { using (var server = new ResponseSocket("@tcp://127.0.0.1:5556")) { while (true) { string frame = server.ReceiveFrameString(); Console.WriteLine(frame); server.SignalOK(); } } }
/// <summary> /// Start listening on udp port /// </summary> public override void Start() { if (_listen) return; try { Log.Info("PortZMq starting"); Log.Debug(string.Format("Publisher binding on {0}", _endpoint)); _res = new ResponseSocket(); _res.Bind(_localpoint); _listen = true; new Thread(() => { try { while (_listen) { byte[] data; while ((_res != null) && _res.HasIn) if (_res.TryReceiveFrameBytes(TimeSpan.FromSeconds(30), out data)) { Log.Debug(string.Format("Received {0} bytes", data.Length)); //Process received data if (!ProcessData(data, data.Length)) { _res.SignalError(); Log.Error(string.Format("Processing {0} bytes failed", data.Length)); } else { _res.SignalOK(); Log.Debug(string.Format("Processed {0} bytes", data.Length)); } } } } catch (Exception e) { Log.Error("PortZMq loop error", e); } }).Start(); base.Start(); } catch (Exception e) { Log.Error("PortZMq start error", e); } }