mirror of
https://github.com/binlaab/nanofiles.git
synced 2026-07-01 18:16:29 +02:00
cosas varias
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package es.um.redes.nanoFiles.tcp.client;
|
||||
package es.um.redes.nanoFiles.tcp.client;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@@ -104,6 +104,13 @@ public class NFConnector {
|
||||
System.out.println("Nos vamos de gfl");
|
||||
return filelist.toArray(new FileInfo[0]);
|
||||
} catch (IOException e) { e.printStackTrace(); return null; }
|
||||
finally {
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean downloadChunk(String hash, int chunkNum, RandomAccessFile raf) {
|
||||
@@ -129,6 +136,13 @@ public class NFConnector {
|
||||
}
|
||||
|
||||
} catch (IOException e) { e.printStackTrace(); }
|
||||
finally {
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package es.um.redes.nanoFiles.tcp.server;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.EOFException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
@@ -49,7 +50,12 @@ public class NFServer implements Runnable {
|
||||
this.stopServer = true;
|
||||
|
||||
try {
|
||||
if (serverSocket != null && !serverSocket.isBound()) {
|
||||
System.out.println("NFServer - tenemos sockets.size() = " + state.getSockets().size());
|
||||
for (Socket s : state.getSockets()) {
|
||||
System.out.println("Socket cerrado? " + s.isClosed());
|
||||
}
|
||||
if (serverSocket != null && serverSocket.isBound()) {
|
||||
System.out.println("Cerramos socket servidor");
|
||||
serverSocket.close();
|
||||
}
|
||||
} catch (IOException e) { e.printStackTrace(); }
|
||||
@@ -172,10 +178,6 @@ public class NFServer implements Runnable {
|
||||
System.out.println("Total connections = " + connNum);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
* TODO: (Boletín SocketsTCP) Añadir métodos a esta clase para: 1) Arrancar el
|
||||
@@ -281,8 +283,19 @@ public class NFServer implements Runnable {
|
||||
}
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
catch (EOFException e) {
|
||||
// nada
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
socket.close();
|
||||
System.out.println("nfserver - cerramos socket de cliente");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user