我有一個服務器監聽端口和IP和客戶端,將連接到此服務器。java數據輸出流發送更多字節
DataInputStream meterin=new DataInputStream(socket.getInputStream);
DataOutputStream modemds=new DataOutputStream(modems.getOutputStream);
現在服務器發送這裏的一些數據:(CA F0 00 00 00 00 00 00 00 3A)。但是,當我看這是
int c;
byte bt[]=new byte[11]
c=meterin.read(bt,0,11)`
System.out.println("bytes"+c) // it is returning 10 bytes
modemds.write(bt,0,c)
,但在客戶端我收到。 (CA F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00)。 即使它向上讀取10個字節也超過10個字節。
你可以添加你用來發送數據的代碼嗎? – 2012-08-11 09:38:56
我認爲*是*用於發送數據的代碼 - 但不清楚爲什麼在循環讀取儘可能多的數據或接收端的代碼時爲什麼不循環。請澄清你的問題,因爲目前很難理解。 – 2012-08-11 09:42:29
哦。那麼問題可能在於客戶。 – 2012-08-11 09:44:26