I've written the below c# Multicast send/receive. It works fine, but after hours and hours of researching and attempting multiple methods, I have been unable to figure out how to receive all of my UDP payload.
UdpClient udpBroadcast = new System.Net.Sockets.UdpClient(2362);
IPEndPoint groupEp = new IPEndPoint(IPAddress.Parse("224.0.5.128"), 2362);
udpBroadcast.Connect(groupEp);
byte[] bData = new byte[] { 0x44, 0x49, 0x47, 0x49, 0x00, 0x01, 0x00, 0x06, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
udpBroadcast.Send(bData, bData.Length);
udpBroadcast.Close();
UdpClient udpResponse = new System.Net.Sockets.UdpClient(2362);
IPEndPoint groupREp = new IPEndPoint(IPAddress.Any, 2362);
Byte[] rMessage = new Byte[4096];
rMessage = udpResponse.Receive(ref groupREp);
string returnData = Encoding.ASCII.GetString(rMessage, 0, rMessage.Length);
Console.WriteLine("Device discovered:");
Console.WriteLine(groupREp.Address.ToString() + " Port:" + groupREp.Port.ToString());
Console.WriteLine(returnData.ToString());
udpResponse.Close();
Below is the full response from the devices when the 'magic word' is sent, the only part I receive back via my code is the "DIGI" chunk (testing with Wireshark open).
0000 c8 60 00 ea ba 7c 00 40 9d 2d e0 77 08 00 45 00 .`...|.@ .-.w..E.
0010 00 9b 00 0d 00 00 40 11 39 f1 c0 a8 be 01 c0 a8 ......@. 9.......
0020 01 02 09 3a 09 3a 00 87 bb b6 44 49 47 49 00 02 ...:.:.. ..DIGI..
0030 00 77 01 06 00 40 9d 2d e0 77 02 04 c0 a8 be 01 .w...@.- .w......
0040 03 04 ff ff ff 00 0b 04 c0 a8 be 01 06 01 00 0d ........ ........
0050 14 50 6f 72 74 53 65 72 76 65 72 20 54 53 20 31 .PortSer ver TS 1
0060 36 20 4d 45 49 07 01 02 08 1d 56 65 72 73 69 6f 6 MEI... ..Versio
0070 6e 20 38 32 30 30 30 36 38 34 5f 54 20 30 38 2f n 820006 84_T 08/
0080 31 38 2f 32 30 30 36 0e 04 00 00 03 03 13 04 00 18/2006. ........
0090 00 04 03 19 01 01 0f 04 00 00 00 00 10 04 00 00 ........ ........
00a0 00 00 12 01 10 0c 02 00 01 ........ .
I really need the whole deal, as mac address, ip, server settings, etc. are all stored there. I know how to read them, but I have no clue how to get at the whole data from c# on the Receive.
Any suggestions/help?