Skip to content
Snippets Groups Projects
Commit 15440b78 authored by Rico's avatar Rico
Browse files

Landas assignment 2 Byte Array clearing fix

parent 1144671d
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,8 @@ public class LandasMulticastReceiver { ...@@ -20,7 +20,8 @@ public class LandasMulticastReceiver {
// buffer of bytes // buffer of bytes
// the incoming bytes containing the information from the server // the incoming bytes containing the information from the server
byte[] buf = new byte[256]; // ** this stored the excess array slot and printed extra
//byte[] buf = new byte[256];
// Multicast socket // Multicast socket
try (MulticastSocket clientSocket = new MulticastSocket(PORT)){ try (MulticastSocket clientSocket = new MulticastSocket(PORT)){
...@@ -28,6 +29,7 @@ public class LandasMulticastReceiver { ...@@ -28,6 +29,7 @@ public class LandasMulticastReceiver {
clientSocket.joinGroup(address); clientSocket.joinGroup(address);
while (true) { while (true) {
byte[] buf = new byte[256];
// Receive information and print // Receive information and print
DatagramPacket msgPacket = new DatagramPacket(buf, buf.length); DatagramPacket msgPacket = new DatagramPacket(buf, buf.length);
clientSocket.receive(msgPacket); clientSocket.receive(msgPacket);
......
...@@ -20,7 +20,8 @@ public class LandasMulticastReceiver2 { ...@@ -20,7 +20,8 @@ public class LandasMulticastReceiver2 {
// buffer of bytes, which will be used to store // buffer of bytes, which will be used to store
// the incoming bytes containing the information from the server // the incoming bytes containing the information from the server
byte[] buf = new byte[256]; // ** this stored the excess array slot and printed extra
//byte[] buf = new byte[256];
// Multicast socket // Multicast socket
try (MulticastSocket clientSocket = new MulticastSocket(PORT)){ try (MulticastSocket clientSocket = new MulticastSocket(PORT)){
...@@ -28,6 +29,7 @@ public class LandasMulticastReceiver2 { ...@@ -28,6 +29,7 @@ public class LandasMulticastReceiver2 {
clientSocket.joinGroup(address); clientSocket.joinGroup(address);
while (true) { while (true) {
byte[] buf = new byte[256];
// Receive information and print // Receive information and print
DatagramPacket msgPacket = new DatagramPacket(buf, buf.length); DatagramPacket msgPacket = new DatagramPacket(buf, buf.length);
clientSocket.receive(msgPacket); clientSocket.receive(msgPacket);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment