mirror of
https://github.com/binlaab/nanofiles.git
synced 2026-07-01 09:40:48 +02:00
gg
This commit is contained in:
6
.classpath
Normal file
6
.classpath
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry kind="src" path=""/>
|
||||||
|
<classpathentry kind="output" path=""/>
|
||||||
|
</classpath>
|
||||||
17
.project
Normal file
17
.project
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>nanofiles</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
BIN
es/um/redes/nanoFiles/application/Directory.class
Normal file
BIN
es/um/redes/nanoFiles/application/Directory.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/application/NanoFiles.class
Normal file
BIN
es/um/redes/nanoFiles/application/NanoFiles.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/logic/NFController.class
Normal file
BIN
es/um/redes/nanoFiles/logic/NFController.class
Normal file
Binary file not shown.
@@ -160,6 +160,12 @@ public class NFController {
|
|||||||
* servidor escucha conexiones de otros peers así como la lista de ficheros
|
* servidor escucha conexiones de otros peers así como la lista de ficheros
|
||||||
* disponibles.
|
* disponibles.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//Comprobamos si ya estamos sirviendo
|
||||||
|
if (controllerPeer.getServerPort() != 0) {
|
||||||
|
System.err.println("* Ya existe un servidor de ficheros activo en el puerto " + controllerPeer.getServerPort());
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (NanoFiles.testModeTCP) {
|
if (NanoFiles.testModeTCP) {
|
||||||
controllerPeer.testTCPServer();
|
controllerPeer.testTCPServer();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
BIN
es/um/redes/nanoFiles/logic/NFControllerLogicDir.class
Normal file
BIN
es/um/redes/nanoFiles/logic/NFControllerLogicDir.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/logic/NFControllerLogicP2P.class
Normal file
BIN
es/um/redes/nanoFiles/logic/NFControllerLogicP2P.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/shell/NFCommands.class
Normal file
BIN
es/um/redes/nanoFiles/shell/NFCommands.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/shell/NFShell.class
Normal file
BIN
es/um/redes/nanoFiles/shell/NFShell.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/tcp/client/NFConnector.class
Normal file
BIN
es/um/redes/nanoFiles/tcp/client/NFConnector.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/tcp/message/PeerMessage.class
Normal file
BIN
es/um/redes/nanoFiles/tcp/message/PeerMessage.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/tcp/message/PeerMessageOps.class
Normal file
BIN
es/um/redes/nanoFiles/tcp/message/PeerMessageOps.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/tcp/message/PeerMessageTest.class
Normal file
BIN
es/um/redes/nanoFiles/tcp/message/PeerMessageTest.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/tcp/server/NFServer.class
Normal file
BIN
es/um/redes/nanoFiles/tcp/server/NFServer.class
Normal file
Binary file not shown.
@@ -278,8 +278,13 @@ public class NFServer implements Runnable {
|
|||||||
msgOut.writeMessageToOutputStream(dos);
|
msgOut.writeMessageToOutputStream(dos);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
System.err.println("* [Servidor] Recibido opcode inesperado o inválido");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
BIN
es/um/redes/nanoFiles/tcp/server/NFServerState.class
Normal file
BIN
es/um/redes/nanoFiles/tcp/server/NFServerState.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/tcp/server/NFServerThread.class
Normal file
BIN
es/um/redes/nanoFiles/tcp/server/NFServerThread.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
es/um/redes/nanoFiles/udp/client/DirectoryConnector.class
Normal file
BIN
es/um/redes/nanoFiles/udp/client/DirectoryConnector.class
Normal file
Binary file not shown.
@@ -6,6 +6,7 @@ import java.net.DatagramSocket;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
|
import java.net.SocketException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@@ -115,21 +116,32 @@ public class DirectoryConnector {
|
|||||||
DatagramPacket pktFromServer = new DatagramPacket(responseData, responseData.length);
|
DatagramPacket pktFromServer = new DatagramPacket(responseData, responseData.length);
|
||||||
int intentos = 0;
|
int intentos = 0;
|
||||||
boolean recibido = false;
|
boolean recibido = false;
|
||||||
|
//Hay que configurar el timeout antes del bucle
|
||||||
|
try {
|
||||||
|
socket.setSoTimeout(TIMEOUT);
|
||||||
|
} catch (SocketException e) {
|
||||||
|
System.err.println("* Error configurando el timeout del socket UDP: " + e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
while (intentos < MAX_NUMBER_OF_ATTEMPTS && !recibido) {
|
while (intentos < MAX_NUMBER_OF_ATTEMPTS && !recibido) {
|
||||||
try {
|
try {
|
||||||
socket.send(pktToServer);
|
socket.send(pktToServer);
|
||||||
socket.setSoTimeout(TIMEOUT);
|
|
||||||
socket.receive(pktFromServer);
|
socket.receive(pktFromServer);
|
||||||
recibido = true;
|
recibido = true;
|
||||||
} catch (IOException e) {
|
//excepciones tratadas
|
||||||
|
} catch (SocketTimeoutException e){
|
||||||
intentos++;
|
intentos++;
|
||||||
if (intentos == MAX_NUMBER_OF_ATTEMPTS) {
|
System.err.println("* Timeout. Reintentando... (" + intentos + "/" + MAX_NUMBER_OF_ATTEMPTS + ")");
|
||||||
System.err.println("DirectoryConnector.sendAndReceiveDatagrams: socket.receive()");
|
} catch (IOException e) {
|
||||||
System.exit(-1);
|
System.err.println("* Error grave de I/O en UDP: " + e.getMessage());
|
||||||
}
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (intentos == MAX_NUMBER_OF_ATTEMPTS) {
|
||||||
|
System.err.println("* El directorio no responde tras " + MAX_NUMBER_OF_ATTEMPTS + " intentos.");
|
||||||
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
String servResp = new String(responseData, 0, pktFromServer.getLength());
|
String servResp = new String(responseData, 0, pktFromServer.getLength());
|
||||||
response = servResp.getBytes();
|
response = servResp.getBytes();
|
||||||
System.out.println("Hemos recibido " + servResp);
|
System.out.println("Hemos recibido " + servResp);
|
||||||
|
|||||||
BIN
es/um/redes/nanoFiles/udp/message/DirMessage.class
Normal file
BIN
es/um/redes/nanoFiles/udp/message/DirMessage.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/udp/message/DirMessageOps.class
Normal file
BIN
es/um/redes/nanoFiles/udp/message/DirMessageOps.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/udp/server/NFDirectoryServer.class
Normal file
BIN
es/um/redes/nanoFiles/udp/server/NFDirectoryServer.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/util/FileDatabase.class
Normal file
BIN
es/um/redes/nanoFiles/util/FileDatabase.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/util/FileDigest.class
Normal file
BIN
es/um/redes/nanoFiles/util/FileDigest.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/util/FileInfo.class
Normal file
BIN
es/um/redes/nanoFiles/util/FileInfo.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/util/FileNameUtil.class
Normal file
BIN
es/um/redes/nanoFiles/util/FileNameUtil.class
Normal file
Binary file not shown.
BIN
es/um/redes/nanoFiles/util/NickGenerator.class
Normal file
BIN
es/um/redes/nanoFiles/util/NickGenerator.class
Normal file
Binary file not shown.
Reference in New Issue
Block a user