UDP packets max size fix
flavien's git/Projet_JAVA_P2P_STRI2A/pipeline/head This commit looks good Details
flavien's git/Projet_JAVA_P2P_STRI2A/pipeline/pr-master This commit looks good Details

pull/100/head
Louis Royer 5 years ago
parent 00170748f4
commit 2b8cd7c73a

@ -30,6 +30,7 @@ import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketAddress;
import java.io.IOException;
import java.util.Arrays;
/** Representation of packet.
* @author Louis Royer
@ -116,9 +117,11 @@ public class ProtocolP2PPacketUDP < T extends Payload> extends ProtocolP2PPacket
throw new InternalError();
}
DatagramSocket ss = (DatagramSocket)socket;
byte[] packet = new byte[1024];
DatagramPacket reception = new DatagramPacket(packet, packet.length);
byte[] packetTmp = new byte[0xFFFF];
DatagramPacket reception = new DatagramPacket(packetTmp, packetTmp.length);
ss.receive(reception);
int payloadSize = Payload.getPayloadSize(packetTmp);
byte[] packet = Arrays.copyOf(packetTmp, Payload.PAYLOAD_START_POSITION + payloadSize);
responseSocketAddress = reception.getSocketAddress();
remoteHost = new HostItem(reception.getAddress().getHostName(), reception.getPort());
// contruction
@ -216,9 +219,11 @@ public class ProtocolP2PPacketUDP < T extends Payload> extends ProtocolP2PPacket
throw new InternalError();
}
// reception
byte[] packet = new byte[8192];
DatagramPacket reception = new DatagramPacket(packet, packet.length);
byte[] packetTmp = new byte[0xFFFF];
DatagramPacket reception = new DatagramPacket(packetTmp, packetTmp.length);
requestSocket.receive(reception);
int payloadSize = Payload.getPayloadSize(packetTmp);
byte[] packet = Arrays.copyOf(packetTmp, Payload.PAYLOAD_START_POSITION + payloadSize);
// contruction
try {

Loading…
Cancel
Save