Hi,
I'm trying to download a file using socket and server in java.
myClient = new Socket(address,port);
myClient.setSoTimeout(MyFileManager.TIME_OUT);
in = new DataInputStream(myClient.getInputStream());
out = new DataOutputStream(myClient.getOutputStream());
File requestedFile = new File(_fileManager.getDir()+fileName); //creating the new file
// requestedFile.createNewFile(); //now it does
fos = new FileOutputStream(requestedFile);
long size = in.readLong(); //get the size
for (int i=1; i<=size; i++) {
try {
fos.write(in.read());
}
catch (IOException e) {
e.printStackTrace();
}
}
I'm sending the other side the file size and then sending each byte, right before the bytes end, it throws the above exception, saying conncetion reset.
what could be the problem?
Thank you!