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