コード例 #1
0
        static async Task Run()
        {
            Console.WriteLine("Starting ZMQ Server");

            var server     = new ResponseSocket();
            var serverCert = CertificatesManager.GetServerCertificate();

            server.Options.CurveServer      = true;
            server.Options.CurveCertificate = serverCert;
            server.Bind(@"tcp://localhost:5556");

            (byte[], bool)socketMsgRequest;

            while (true)
            {
                socketMsgRequest = await server.ReceiveFrameBytesAsync().ConfigureAwait(false);

                if (!socketMsgRequest.Item2)
                {
                    break;
                }
            }

            var receivedMsg = Message.Parser.ParseFrom(socketMsgRequest.Item1);

            Console.WriteLine("From Client: {0} - {1}", receivedMsg.Id, receivedMsg.Data);

            server.SendFrame(
                (new Message()
            {
                Id = 2,
                Data = "Response from server",
            })
                .ToByteArray());
        }