I transmit data using an UDP connection to the program on my server. The data is transmitted by an modem from Quectel BC66. The AT command from terminal is shown below:
AT+QISEND=0,20,12345678910111213112
OK
SEND OK
When the data appears on the server instead of showing the data which was sent it shows question marks:
The code of the program is shown below:
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();
}
}
}
}
Do you have any suggestion on how to show the sent data identical on the server program?