-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWebServer.java
34 lines (32 loc) · 890 Bytes
/
WebServer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.io.*;
import java.net.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class WebServer implements Runnable {
int port;
Entite e;
public WebServer(int port, Entite e)
{
this.port = port;
this.e = e;
}
public void run()
{
try {
ServerSocket serverSock = new ServerSocket(port);
System.out.println("Serveur web lancé");
int c = 0;
while (true) {
System.out.println("[WEB] En attente d'une connexion sur le port "+port);
System.out.println(++c);
Socket s = serverSock.accept();
Thread wc = new Thread(new WebServerClient(s,e));
wc.start();
}
}catch(Exception e)
{
e.printStackTrace();
}
}
}