UDP packets max size fix
This commit is contained in:
parent
00170748f4
commit
2b8cd7c73a
@ -30,6 +30,7 @@ import java.net.DatagramPacket;
|
|||||||
import java.net.DatagramSocket;
|
import java.net.DatagramSocket;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/** Representation of packet.
|
/** Representation of packet.
|
||||||
* @author Louis Royer
|
* @author Louis Royer
|
||||||
@ -116,9 +117,11 @@ public class ProtocolP2PPacketUDP < T extends Payload> extends ProtocolP2PPacket
|
|||||||
throw new InternalError();
|
throw new InternalError();
|
||||||
}
|
}
|
||||||
DatagramSocket ss = (DatagramSocket)socket;
|
DatagramSocket ss = (DatagramSocket)socket;
|
||||||
byte[] packet = new byte[1024];
|
byte[] packetTmp = new byte[0xFFFF];
|
||||||
DatagramPacket reception = new DatagramPacket(packet, packet.length);
|
DatagramPacket reception = new DatagramPacket(packetTmp, packetTmp.length);
|
||||||
ss.receive(reception);
|
ss.receive(reception);
|
||||||
|
int payloadSize = Payload.getPayloadSize(packetTmp);
|
||||||
|
byte[] packet = Arrays.copyOf(packetTmp, Payload.PAYLOAD_START_POSITION + payloadSize);
|
||||||
responseSocketAddress = reception.getSocketAddress();
|
responseSocketAddress = reception.getSocketAddress();
|
||||||
remoteHost = new HostItem(reception.getAddress().getHostName(), reception.getPort());
|
remoteHost = new HostItem(reception.getAddress().getHostName(), reception.getPort());
|
||||||
// contruction
|
// contruction
|
||||||
@ -216,9 +219,11 @@ public class ProtocolP2PPacketUDP < T extends Payload> extends ProtocolP2PPacket
|
|||||||
throw new InternalError();
|
throw new InternalError();
|
||||||
}
|
}
|
||||||
// reception
|
// reception
|
||||||
byte[] packet = new byte[8192];
|
byte[] packetTmp = new byte[0xFFFF];
|
||||||
DatagramPacket reception = new DatagramPacket(packet, packet.length);
|
DatagramPacket reception = new DatagramPacket(packetTmp, packetTmp.length);
|
||||||
requestSocket.receive(reception);
|
requestSocket.receive(reception);
|
||||||
|
int payloadSize = Payload.getPayloadSize(packetTmp);
|
||||||
|
byte[] packet = Arrays.copyOf(packetTmp, Payload.PAYLOAD_START_POSITION + payloadSize);
|
||||||
|
|
||||||
// contruction
|
// contruction
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user