【问题标题】:Why does the question mark appear when sending data to server?为什么发送数据到服务器时会出现问号?
【发布时间】:2020-01-29 13:28:36
【问题描述】:

我使用 UDP 连接将数据传输到我服务器上的程序。数据由 Quectel BC66 的调制解调器传输。终端的 AT 指令如下:

AT+QISEND=0,20,12345678910111213112

OK

SEND OK

当数据出现在服务器上而不是显示发送的数据时,它会显示问号:

程序代码如下:

class Program
    {
        static void Main(string[] args)
        {
            try
            {
                IPEndPoint ip = new IPEndPoint(IPAddress.Any, 29030);
                UdpClient server = new UdpClient(ip);
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("[UDP] [Listenning]");
                while (true)
                {
                    byte[] data = server.Receive(ref ip);
                    string ch = Encoding.Unicode.GetString(data, 0, data.Length);
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(ch + " " + DateTime.Now.ToString());
                    string serv_msg = "Server received the data";
                    byte[] msg = Encoding.Unicode.GetBytes(serv_msg);
                    server.Send(msg, msg.Length, ip);
                    server.Send(new byte[] { 1 }, 1, ip);
                }
            }
            catch
            {
                Console.WriteLine("Warrning:connection failed");
                Console.ReadKey();
            }
        }
    }
}

您对如何在服务器程序上显示相同的发送数据有什么建议吗?

【问题讨论】:

    标签: c# server udp iot quectel


    【解决方案1】:

    您的终端应用程序似乎不支持您尝试显示的 Unicode 字符。

    尝试更改您的设置以允许使用 unicode 字符或切换到另一个终端模拟器,例如 ConEmu

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-11
      • 2016-06-07
      • 2018-05-07
      相关资源
      最近更新 更多