"Сброс соединения по узлу: ошибка записи сокета"
Размер файла который я передаю, составляет 96 МБ.
(clientSocket — это SSLSocket)
Клиент:
Activity_1 Class :
Код: Выделить всё
clientSocket = (SSLSocket) sslContext.getSocketFactory().createSocket();
clientSocket.connect(...);
clientSocket.setEnabledCipherSuites(clientSocket.getSupportedCipherSuites());
clientSocket.startHandshake();
Код: Выделить всё
SSLSocket clientSocket = Activity_1.clientSocket;
final DataInputStream dis = new DataInputStream(clientSocket.getInputStream());
int n = 0;
final byte[] buf = new byte[8192];
fos = new new FileOutputStream....
while ((n = dis.read(buf)) != -1) {
counter += n;
fos.write(buf, 0, n);
runOnUiThread(new Runnable() {
@Override
public void run() {
...
}
});
}
if (counter >= file_size) {
System.out.println("CLOSED");
fos.flush();
fos.close();
clientSocket.close();
}
Код: Выделить всё
FileInputStream fis = new FileInputStream...
BufferedInputStream bis = new BufferedInputStream(fis);
DataInputStream dis = new DataInputStream(bis);
byte[] mybytearray = new byte[8192];
OutputStream os;
try {
os = clientSocket.getOutputStream();
DataOutputStream dos = new DataOutputStream(os);
int read = -1;
while ((read = dis.read(mybytearray)) > -1) {
dos.write(mybytearray, 0, read);
}
System.out.println("CLOSED");
dos.flush();
dos.close();
dis.close();
} catch (IOException e) {
e.printStackTrace();
}
Подробнее здесь: https://stackoverflow.com/questions/357 ... large-file