Exemple #1
0
    // Client thread which does not block Update()
    void NetMQClient()
    {
        AsyncIO.ForceDotNet.Force();
        NetMQConfig.ManualTerminationTakeOver();
        NetMQConfig.ContextCreate(true);

        //string msg;
        var timeout = new System.TimeSpan(0, 0, 1); //1sec

        Debug.Log("Connect to the server.");

        pairSocket = new NetMQ.Sockets.PairSocket();
        pairSocket.Options.ReceiveHighWatermark = 0;
        //pairSocket.Connect("tcp://192.168.1.122:55555");
        pairSocket.Connect("tcp://192.168.1.111:55555");

        is_connected = true;

        while (is_connected && stop_thread_ == false)
        {
            is_connected = pairSocket.TryReceiveFrameString(timeout, out msg);
            pairSocket.TrySendFrame(timeout, final);
        }

        pairSocket.Close();
        Debug.Log("ContextTerminate.");
        NetMQConfig.ContextTerminate();
        NetMQConfig.Cleanup();
    }
Exemple #2
0
        public static void CreateSocketPair(out PairSocket socket1, out PairSocket socket2)
        {
            string address = string.Format("inproc://NetMQSocketPair#{0}", Interlocked.Increment(ref s_sequence));

            socket1 = new PairSocket();
            socket1.Bind(address);

            socket2 = new PairSocket();
            socket2.Connect(address);
        }
Exemple #3
0
        /// <summary>
        /// Create and return an inproc pipe where socket1 is bound and socket2 is connected.
        /// </summary>
        /// <param name="socket1">the Bind socket</param>
        /// <param name="socket2">the Connect socket</param>
        public static void CreateSocketPair(out PairSocket socket1, out PairSocket socket2)
        {
            string address = $"inproc://NetMQSocketPair#{Interlocked.Increment(ref s_sequence)}";

            socket1 = new PairSocket();
            socket1.Bind(address);

            socket2 = new PairSocket();
            socket2.Connect(address);
        }