feat: scanner udp
This commit is contained in:
@@ -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()
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
app/src/main/java/clientserver/Server.java
Normal file
18
app/src/main/java/clientserver/Server.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user