Why is Android sending this symbol?(�)
What I’m doing is, get a few variables, put them altogether, and then send using Multicast. The symbols occur only in the end of the String, and repeat a lot.
byte[] buffer;
String temp1 = "temp1=" + "37";
String weight1 = "weight1=" + "68";
String bpm = "bpm=" + "128";
String angBack = "angback=" + "90";
String angLeg = "angleg=" + "90";
String angBed = "angbed=" + "91";
String msg = "status:teste," + temp1 + "," + weight1 + "," + bpm + "," + angBack +
"," + angLeg + "," + angBed;
buffer = msg.getBytes();
InetAddress group = InetAddress.getByName("230.0.0.1");
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, group, 5556);
socket.send(packet);
Then on the other side, I get the String, and those symbols appear at the end of the String.
byte[] buffer = new byte[256];
DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
multicastSocket.receive(packet);
String msg = new String(packet.getData());
Why is this happening?
This is not a weird symbol it’s just
0x00.You’re writing whole buffer, check the data length.