Merge remote-tracking branch 'origin/master'
This commit is contained in:
90
.gitignore
vendored
90
.gitignore
vendored
@@ -231,4 +231,92 @@ Network Trash Folder
|
|||||||
Temporary Items
|
Temporary Items
|
||||||
.apdisk
|
.apdisk
|
||||||
|
|
||||||
# End of https://www.gitignore.io/api/osx,java,linux,maven,eclipse,intellij
|
### Intellij+all ###
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/usage.statistics.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# AWS User-specific
|
||||||
|
.idea/**/aws.xml
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
.idea/**/contentModel.xml
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# Gradle and Maven with auto-import
|
||||||
|
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||||
|
# since they will be recreated, and may cause churn. Uncomment if using
|
||||||
|
# auto-import.
|
||||||
|
# .idea/artifacts
|
||||||
|
# .idea/compiler.xml
|
||||||
|
# .idea/jarRepositories.xml
|
||||||
|
# .idea/modules.xml
|
||||||
|
# .idea/*.iml
|
||||||
|
# .idea/modules
|
||||||
|
# *.iml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# SonarLint plugin
|
||||||
|
.idea/sonarlint/
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
|
||||||
|
# Android studio 3.1+ serialized cache file
|
||||||
|
.idea/caches/build_file_checksums.ser
|
||||||
|
|
||||||
|
### Intellij+all Patch ###
|
||||||
|
# Ignore everything but code style settings and run configurations
|
||||||
|
# that are supposed to be shared within teams.
|
||||||
|
|
||||||
|
.idea/*
|
||||||
|
|
||||||
|
!.idea/codeStyles
|
||||||
|
!.idea/runConfigurations
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/intellij+all
|
||||||
16
src/main/java/pr/tp2/udp/chat/ChatMulticast.java
Normal file
16
src/main/java/pr/tp2/udp/chat/ChatMulticast.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package pr.tp2.udp.chat;
|
||||||
|
|
||||||
|
public class ChatMulticast {
|
||||||
|
|
||||||
|
private static class Receiver implements Runnable {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// Code de reception et affichage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// Lecture au clavier et envoie du message
|
||||||
|
// Vous pouvez utiliser Scanner : https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Scanner.html
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package pr.tp2.udp.discovery;
|
|
||||||
|
|
||||||
public class Discovery {
|
|
||||||
|
|
||||||
public static void sendWhois(String id) {
|
|
||||||
// Envoie un message Whois
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendLeaving(String id) {
|
|
||||||
// Envoie un message Leaving
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendIAM(String id, String url) {
|
|
||||||
// Envoie un message IAM
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void listenAndReply() {
|
|
||||||
// Ecoute et affiche les évennements IAM,LEAVING
|
|
||||||
|
|
||||||
// Réponds aux WHOIS si ID = ID
|
|
||||||
// URL du service :
|
|
||||||
String ID = "051005022";
|
|
||||||
String URL = "https://istic.univ-rennes1.fr/";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
String cmd = args[0], url = null, id = null;
|
|
||||||
if (args.length > 1) {
|
|
||||||
id = args[1];
|
|
||||||
}
|
|
||||||
if (args.length == 3) {
|
|
||||||
url = args[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (cmd) {
|
|
||||||
case "listen":
|
|
||||||
listenAndReply();
|
|
||||||
break;
|
|
||||||
case "iam":
|
|
||||||
sendIAM(id, url);
|
|
||||||
break;
|
|
||||||
case "leaving":
|
|
||||||
sendLeaving(id);
|
|
||||||
break;
|
|
||||||
case "whois":
|
|
||||||
sendWhois(id);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
System.out.println("Erreur de commande");
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package pr.tp2.udp.discovery;
|
|
||||||
|
|
||||||
public class TestDiscovery {
|
|
||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException {
|
|
||||||
Runnable listener = () -> {
|
|
||||||
Discovery.listenAndReply();
|
|
||||||
};
|
|
||||||
new Thread(listener).start();
|
|
||||||
|
|
||||||
Discovery.sendWhois("051005022");
|
|
||||||
Discovery.sendIAM("tftp", "127.0.0.1:6969");
|
|
||||||
|
|
||||||
Thread.sleep(10000);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,33 +3,52 @@ 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.InetSocketAddress;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
|
|
||||||
public class TftpPutServeur {
|
public class TftpPutServeur {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
try {
|
||||||
// Attends sur le port 6969
|
// Attends sur le port 6969
|
||||||
|
DatagramSocket socket = new DatagramSocket(6969);
|
||||||
|
|
||||||
// Boucle
|
// Boucle
|
||||||
|
while(true){
|
||||||
|
byte buffer[] = new byte[100];
|
||||||
|
|
||||||
// Reception du packet
|
// Reception du packet
|
||||||
DatagramPacket p = null;
|
DatagramPacket p = new DatagramPacket(buffer, buffer.length);
|
||||||
|
socket.receive(p);
|
||||||
|
|
||||||
|
String requete = new String(buffer);
|
||||||
|
|
||||||
// Affichage du packet
|
// Affichage du packet
|
||||||
|
System.out.println("requete : " + requete);
|
||||||
|
|
||||||
// Attention à ne pas afficher plus d'informations que nécessaire.
|
// Attention à ne pas afficher plus d'informations que nécessaire.
|
||||||
|
//System.out.println("plus d'informations que nécessaire");
|
||||||
|
|
||||||
// Décodage du packet
|
// Décodage du packet
|
||||||
decodeRequest(p);
|
decodeRequest(p);
|
||||||
|
|
||||||
// Envoyer acquittement
|
// Envoyer acquittement
|
||||||
// sendAck(server, /***/);
|
short seq = 2;
|
||||||
|
sendAck(socket,seq,new InetSocketAddress(p.getAddress(), p.getPort())); //TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendAck(DatagramSocket server, short seqNumber, SocketAddress dstAddr) throws IOException {
|
public static void sendAck(DatagramSocket server, short seqNumber, SocketAddress dstAddr) throws IOException {
|
||||||
System.out.println("Send " + seqNumber + " to " + dstAddr);
|
System.out.println("Send " + seqNumber + " to " + dstAddr);
|
||||||
|
|
||||||
// Construire le paquet avec les bonnes informations
|
// Construire le paquet avec les bonnes informations
|
||||||
|
byte[] ackBytes = "ack".getBytes();
|
||||||
|
DatagramPacket p = new DatagramPacket(ackBytes,ackBytes.length,dstAddr);
|
||||||
|
server.send(p);
|
||||||
|
|
||||||
// afficher le tableau de bytes envoyé
|
// afficher le tableau de bytes envoyé
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user