내가 파일 보내기 전에 서버의 크기와 같은 메타 데이터를 전송자바 서버 안드로이드 클라이언트 와이파이 전송 파일, 소켓 오류
클라이언트 서버 (바탕 화면 APP) (안드로이드)에서 파일을 보내는 몇 가지 문제를 ....이 파일 이름 등 .....
서버 측 전송 방법 :
@Override
protected String doInBackground(Void... params) {
String pathToPdf = "";
if (pdf.getLength() > 0) {
InputStream is;
try {
byte b = 0;
clientSocket.getOutputStream().write(b);
is = clientSocket.getInputStream();
pathToPdf = pathToExternalStorageFolder+pdf.getMeta().getName();
pathToPdf = pathToPdf.replace(".\\", "/");
pathToPdf = pathToPdf.replace("\\", "/");
int size = pdf.getLength();
byte[] buffor = new byte[1024];
int current = 0;
int count = 0;
if (pdf.getMeta() != null) {
FileOutputStream fos = new FileOutputStream(pathToPdf);
while (count < size) {
current = is.read(buffor, 0, buffor.length);
fos.write(buffor, 0, current);
count += current;
}
fos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return pathToPdf;
}
,536,913,632 :
private void sendPdfData(OutputStream os, File file) throws IOException {
os.flush();
FileInputStream fis = new FileInputStream(file);
byte[] buffor = new byte[1024];
long count = 0L;
long size = file.length();
int current = 0;
while (count < size) {
current = fis.read(buffor, 0, buffor.length);
os.write(buffor, 0, current);
count += current;
}
fis.close();
os.flush();
}
클라이언트 측 방법을받을 파일을 전송 10
어떤 임의의 오류 :
java.net.SocketException: Software caused connection abort: socket write error
java.net.SocketException: Connection reset by peer: socket write error
File size: 2317679
Sended: 44032
UPDATE 2013년 9월 8일
나는 서버 응용 프로그램을 확인하는 데스크톱 클라이언트 응용 프로그램을 만들 수 있습니다. NetBeans에서 서버와 클라이언트를 모두 실행하면 모든 것이 잘 실행되므로 인터페이스 주소 (lopback 아님)를 사용합니다. jar에서 클라이언트를 실행할 때 문제가 있습니다. 파일 목록이 null이지만 서버 측에서 null이 아니며 비어 있지 않습니다. 안드로이드에서 연결할 때 wtfigo - magic 파일 목록이 나타납니다.
흠에
autoReconnect=true
를 추가, 왜 U 그것이 JDBC 측면에서 문제가 말할? 소켓을 기반으로하는 서버 - 클라이언트 측 연결 만 사용합니다. 파일을 보낼 때 jdbc를 사용하지 마십시오. 나는 리눅스에서 이것을 시도 할 수있다. – NerusLinux에서 테스트했지만 작동하지 않습니다. (Linux 및 Windows와 동일한 문제) – Nerus