/// <summary> /// Forwards requests from the frontend socket to the backend socket. /// </summary> protected override bool FrontendHandler(ZSocket sock, out ZMessage message, out ZError error) { error = default(ZError); message = null; // receiving scope // STREAM: get 2 frames, identity and body ZMessage incoming = null; // IPAddress address = null; string address; if (!ReceiveMsg(sock, ref incoming, out address, out error)) { return(false); } // sending scope // DEALER: forward using (incoming) { if (incoming[1].Length == 0) { return(true); // Ignore the Empty one } // Prepend empty delimiter between Identity frame and Data frame incoming.Insert(1, new ZFrame()); // Prepend Peer-Address incoming.Insert(2, new ZFrame(address)); try { if (!BackendSocket.Send(incoming, /* ZSocketFlags.DontWait, */ out error)) { return(false); } } finally { incoming.Dismiss(); } } return(true); }