-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.java
More file actions
37 lines (31 loc) · 901 Bytes
/
Server.java
File metadata and controls
37 lines (31 loc) · 901 Bytes
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
35
36
37
import java.io.IOException;
import java.net.ServerSocket;
public class Server{
private ServerSocket servidor;
private boolean escutando = true;
public Server(){
try{
System.out.println("Iniciando o servidor....");
this.servidor = new ServerSocket(8081);
System.out.println("Servidor iniciado na porta 8081.");
}
catch(Exception e){
System.out.println(e.getMessage());
}
}
public void run(){
while(escutando){
try{
new ServerThread(servidor.accept()).run();
}
catch(IOException e){
System.out.println(e.getMessage());
System.exit(-1);
}
}
}
public static void main(String[] args){
Server servidor = new Server();
servidor.run();
}
}