我正在尝试通过TCP发送十六进制数据。
我知道如何在UDP中执行此操作,但TCP不适用于我:
TcpClient client = new TcpClient("192.168.1.202", 8000);
NetworkStream stream = client.GetStream();
ASCIIEncoding Enc = new ASCIIEncoding();
Byte[] s = new byte[] { 0xa5, 0x5b, 0x02, 0x03, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07 };
Console.WriteLine(s.ToString());
答案 0 :(得分:0)
我已经这样解决了:
TcpClient client = new TcpClient("192.168.1.202", 8000);
Byte[] s = new byte[] { 0xa5, 0x5b, 0x02, 0x03, 0x01, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0xf9 };
NetworkStream stream = client.GetStream();
stream.Write(s, 0, s.Length);