out = new DataOutputStream(connection.getOutputStream());
String process;
System.out.println("Connecting to server on "+ host + " port " + port +" at " + timestamp);
process = "Connection: "+host + ","+port+","+timestamp;
System.out.println("client len " + process.length());
out.write(process.length());
打印: 客戶len個55
服務器端:
in = new DataInputStream(connection.getInputStream());
while (true) {
int len = in.readInt();
System.out.println("Length of pkt: "+len);
打印:927166318
這是怎麼回事:PKT的長度?我試着寫0,它在服務器端打印3621743。我檢查了其他一些網站,並且有幾個人遇到了其他流問題。我閱讀了關於大vs小序列出現的問題,但我不確定這裏存在什麼問題,因爲我使用的數據流應該可以正常工作。
完美。我知道這是基本的。謝謝您的幫助! – Rahul 2014-10-10 22:31:23