bpa wrote:
> I've tried this string in Perl, Javascript and Python (and squeezelite
> uses C) so either you're not reading all the chars received or the
> string sent is not correct.
>
> Many langauge which support UTF may enacode them as 16 bit. Each char is
> 16 bit and also says length is number of 16 bit chars not 8 bit bytes.
>
> An independent check would be to use wireshark.
>
> Why don't you encode as ASCII to be sure ? this example seems to so
> ASCII encoding
> https://social.msdn.microsoft.com/Forums/en-US/baa3a5bb-2154-445f-965d-8a139dbe932a/c-udp-broadcast-send-and-receive?forum=netfxnetcom
Success !!! - here is what I did
Code:
--------------------
int UDPPort = 3483;
UdpClient listener = new UdpClient(UDPPort);
IPEndPoint ReceiveIP = new IPEndPoint(IPAddress.Any, UDPPort);
// Notice I escape the 0 terminator.
Char[] request = {
'e',
'I', 'P', 'A', 'D', '\0',
'N', 'A', 'M', 'E', '\0',
'J', 'S', 'O', 'N', '\0',
};
Byte[] RequestData = Encoding.ASCII.GetBytes(request);
listener.Receive(ref ReceiveIP); // This populates ReceiveIP with the ip
address of the server that responded.
int BytesSent = listener.Send(RequestData, RequestData.Length, ReceiveIP); //
Now send our request.
byte[] BytesReceived = listener.Receive(ref ReceiveIP); // Get the response
data ( "ENAME\bmax2playJSON9000" is returned in a byte array )
String RetVal = Encoding.ASCII.GetBytes(BytesReceived);
// The port number is all the digits following JSON which is easily parsed
--------------------
Thanks for all your help.
We can't stop here this is bat country. RIP Hunter S Thompson.
------------------------------------------------------------------------
pkfox's Profile: http://forums.slimdevices.com/member.php?userid=5346
View this thread: http://forums.slimdevices.com/showthread.php?t=105040
_______________________________________________
discuss mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/discuss