0
inFromClientR.readLine()
永不停息。有任何想法嗎?我忘記了什麼嗎?readLine()永不停止閱讀
服務器:
/*{ some code:
send a file with a dataoutputstream to client using a new port(4000) and when transfer is done i want a responce message (e.g. OK) send back to server in the old port(6000)
}*/
ServerSocket listenTransferSocket = new ServerSocket(6000);
Socket connectionTransferSocket = listenTransferSocket.accept();
BufferedReader inFromClientR =
new BufferedReader(new InputStreamReader(connectionTransferSocket.getInputStream()));
System.out.println("Client's response to Transfer: " +inFromClientR.readLine());
客戶:
/*{ some code:
receive the file on port (4000) and then the responce is sent to server using the following commands
}*/
Socket fileTransferSocket = new Socket("localhost", 6000);
DataOutputStream outToServerR =
new DataOutputStream(fileTransferSocket.getOutputStream());
outToServerR.writeBytes("Transfer completed " +'\n');
寫完「Transfer completed」消息後,你是否在flush()流? – mthmulders 2013-04-04 09:07:27
是的,我在客戶端做了........ – Nicolaos 2013-04-04 09:09:35
outToServerR.writeBytes(「Transfer completed」+'\ n');永不停止。該行之後的println從不顯示 – Nicolaos 2013-04-04 09:10:53