ok
This commit is contained in:
@@ -3,37 +3,33 @@ package pr.tp2.udp.tftp;
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
public class TftpDecode {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
int portTFTP = 7777;
|
||||
int portServeur= 6969;
|
||||
InetAddress ipServeur = InetAddress.getByName("localhost");
|
||||
try{
|
||||
// Attends sur le port 6969
|
||||
DatagramSocket dSocket = new DatagramSocket(portTFTP);
|
||||
int portServeur = 6969;
|
||||
DatagramSocket dSocket = null;
|
||||
try {
|
||||
// Attends sur le port 6969
|
||||
dSocket = new DatagramSocket(portServeur);
|
||||
// Boucle
|
||||
while (true) {
|
||||
byte[] buffer = new byte[21];
|
||||
// Reception du packet
|
||||
DatagramPacket reception = new DatagramPacket(buffer, buffer.length);
|
||||
dSocket.receive(reception);
|
||||
// Affichage du packet
|
||||
affiche(buffer);
|
||||
// Attention à ne pas afficher plus d'informations que nécessaire.
|
||||
|
||||
// Boucle
|
||||
while (true) {
|
||||
byte[] buffer = new byte[512];
|
||||
// Reception du packet
|
||||
DatagramPacket reception =new DatagramPacket(buffer, buffer.length);
|
||||
dSocket.receive(reception);
|
||||
|
||||
// Affichage du packet
|
||||
System.out.println(new String(buffer));
|
||||
|
||||
// Attention à ne pas afficher plus d'informations que nécessaire.
|
||||
|
||||
// Décodage du packet
|
||||
decodeRequest(reception);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// Décodage du packet
|
||||
decodeRequest(reception);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
dSocket.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static void affiche(byte[] bytes) {
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user