0
public static void ZeroMQ()
{
    try
    {
        TimeSpan timeout = TimeSpan.FromMilliseconds(2000);
        AsyncIO.ForceDotNet.Force();
        using (PairSocket client = new PairSocket("tcp://127.0.0.1:5555"))
        {
            client.Options.SendHighWatermark = 0;
            client.Options.Linger = TimeSpan.Zero;
            bool success = client.TrySendFrame(timeout, "Hello");
            Debug.Log($"Success = {success}");
            string msg = string.Empty;
            success = client.TryReceiveFrameString(timeout, out msg);
            Debug.Log($"Success = {success} - {msg}");
            success = client.TryReceiveFrameString(timeout, out msg);
            Debug.Log($"Success = {success} - {msg}");
        }
    }
    catch (Exception e)
    {
        Debug.Log(e);
    }
    finally
    {
        NetMQConfig.Cleanup();
    }
}

Here's some code with two problems:

  1. If I run this code with no server running on :5555, this program prints "Success = true" for the TrySendFrame(), and false for both receives. I would expect it to fail and can't get it to fail even with Linger set to 0 and the high water mark also set to zero.
  2. The second issue is that after the execution hits the finally block, the program freezes forever.

Can someone better versed in ZMQ give me any pointers as to why this might be happening?

Programmer9000
  • 1,959
  • 3
  • 17
  • 27

0 Answers0