-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServidor.java
More file actions
35 lines (29 loc) · 1.02 KB
/
Servidor.java
File metadata and controls
35 lines (29 loc) · 1.02 KB
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
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
public class Servidor {
private static List<Threads> clients = new ArrayList<>();
public static void main(String[] args) throws IOException{
ServerSocket serverSocket = new ServerSocket(55573);
System.out.println("Porta 55573 aberta!!");
System.out.println("Esperando cliente se conectar");
try{
while (true) {
Socket socket = serverSocket.accept();
System.out.println("Cliente Conectado");
Thread clientsThread = new Threads(socket);
clients.add((Threads) clientsThread);
clientsThread.start();
}
}catch (IOException e){
e.printStackTrace();
}
}
public static List<Threads> getClients(){
return clients;
}
}