feat: scanner udp

This commit is contained in:
Morph01
2025-03-25 16:25:56 +01:00
parent 75ce8aa2c9
commit 938bd5c601
3 changed files with 24 additions and 3 deletions

View File

@@ -10,6 +10,10 @@ plugins {
id 'application' id 'application'
} }
application {
mainClass = 'clientserver.App'
}
repositories { repositories {
// Use Maven Central for resolving dependencies. // Use Maven Central for resolving dependencies.
mavenCentral() mavenCentral()

View File

@@ -1,6 +1,3 @@
/*
* This source file was generated by the Gradle 'init' task
*/
package clientserver; package clientserver;
public class App { public class App {
@@ -10,5 +7,7 @@ public class App {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(new App().getGreeting()); System.out.println(new App().getGreeting());
Server.scannerUDP(1000, 5000);
} }
} }

View File

@@ -0,0 +1,18 @@
package clientserver;
import java.net.DatagramSocket;
public class Server {
static void scannerUDP(int startPort, int endPort) {
try {
for (int i = startPort; i < endPort; i++) {
try (DatagramSocket socket = new DatagramSocket(i)) {
} catch (Exception e) {
System.out.println("Port n°" + i + " déjà occupé");
}
}
} catch (Exception e) {
System.out.println(e);
}
}
}