|
|
|
@ -4,6 +4,7 @@ import exception.ProtocolError;
|
|
|
|
|
import exception.SizeError;
|
|
|
|
|
import exception.TransmissionError;
|
|
|
|
|
import exception.VersionError;
|
|
|
|
|
import remoteException.EmptyFile;
|
|
|
|
|
import remoteException.EmptyDirectory;
|
|
|
|
|
import remoteException.InternalRemoteError;
|
|
|
|
|
import remoteException.NotFound;
|
|
|
|
@ -92,7 +93,9 @@ public class ClientManagementUDP implements Runnable {
|
|
|
|
|
} catch (VersionRemoteError e) {
|
|
|
|
|
System.err.println("Error: Server cannot decode this version of the protocol");
|
|
|
|
|
} catch (NotFound e) {
|
|
|
|
|
System.err.println("Error: Server have not this file in directory");
|
|
|
|
|
System.err.println("Error: Server has not this file in directory");
|
|
|
|
|
} catch (EmptyFile e) {
|
|
|
|
|
System.err.println("Error: File is empty");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -109,8 +112,9 @@ public class ClientManagementUDP implements Runnable {
|
|
|
|
|
* @throws InternalRemoteError
|
|
|
|
|
* @throws ProtocolRemoteError
|
|
|
|
|
* @throws VersionRemoteError
|
|
|
|
|
* @throws EmptyFile
|
|
|
|
|
*/
|
|
|
|
|
private void download(String filename) throws NotFound, InternalError, UnknownHostException, IOException, TransmissionError, ProtocolError, VersionError, SizeError, InternalRemoteError, ProtocolRemoteError, VersionRemoteError {
|
|
|
|
|
private void download(String filename) throws EmptyFile, NotFound, InternalError, UnknownHostException, IOException, TransmissionError, ProtocolError, VersionError, SizeError, InternalRemoteError, ProtocolRemoteError, VersionRemoteError {
|
|
|
|
|
ProtocolP2PDatagram d = new ProtocolP2PDatagram((Payload) new LoadRequest(filename));
|
|
|
|
|
d.send(socket, host, UDPPort);
|
|
|
|
|
try {
|
|
|
|
@ -168,6 +172,8 @@ public class ClientManagementUDP implements Runnable {
|
|
|
|
|
}
|
|
|
|
|
} catch (NotFound e) {
|
|
|
|
|
throw new ProtocolError();
|
|
|
|
|
} catch (EmptyFile e) {
|
|
|
|
|
throw new ProtocolError();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|