quemen redes

This commit is contained in:
binlaab
2026-04-20 22:38:38 +02:00
parent aa8b7b30fb
commit 25bf19ee9c
15 changed files with 414 additions and 42 deletions

View File

@@ -1,6 +1,7 @@
package es.um.redes.nanoFiles.logic;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.io.IOException;
import es.um.redes.nanoFiles.tcp.client.NFConnector;
import es.um.redes.nanoFiles.application.NanoFiles;
@@ -46,7 +47,21 @@ public class NFControllerLogicP2P {
*
*/
try {
fileServer = new NFServer();
ServerSocket serverSocket = fileServer.getServerSocket();
if (serverSocket.isBound()) {
System.out.println("Server socket listening on port " + serverSocket.getLocalPort());
serverRunning = true;
}
Thread mainServerThread = new Thread(fileServer);
mainServerThread.start();
} catch (IOException e) {
e.printStackTrace();
System.err.println("Cannot start the file server");
fileServer = null;
}
}
@@ -86,7 +101,7 @@ public class NFControllerLogicP2P {
assert (NanoFiles.testModeTCP);
/*
* (Boletín SocketsTCP) Inicialmente, se creará un NFConnector (cliente TCP)
* para conectarse a un servidor que esté escuchando en la misma máquina y un
* para conectarse a un servidor que esté escuchando en la m isma máquina y un
* puerto fijo. Después, se ejecutará el método "test" para comprobar la
* comunicación mediante el socket TCP. Posteriormente, se desactivará
* "testModeTCP" para implementar la descarga de un fichero desde múltiples
@@ -95,6 +110,7 @@ public class NFControllerLogicP2P {
try {
NFConnector nfConnector = new NFConnector(new InetSocketAddress(NFServer.PORT));
// meter la ip como primer argumento a InetSocketAddress()
nfConnector.test();
} catch (IOException e) {
// TODO Auto-generated catch block