|
|
|
@ -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 {
|
|
|
|
|