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
 void OnApplicationQuit()
 {
     if (zmqSocket != null)
     {
         zmqSocket.Close();
     }
     NetMQConfig.Cleanup();
 }