0
我用下面的代碼互聯網連接連接得到了一段時間
HttpConnection httpConn = null;
DataOutputStream dataOS = null;
redemptionUrl = redemptionUrl+ ";deviceside=true";
httpConn = (HttpConnection) Connector.open(redemptionUrl);
httpConn.setRequestProperty("User-Agent",
"Profile/MIDP-1.0, Configuration/CLDC-1.0");
httpConn.setRequestProperty("Connection", "Keep-Alive");
httpConn.setRequestProperty("Content-Language", "en-US");
httpConn.setRequestMethod(HttpConnection.POST);
dataOS = (DataOutputStream) httpConn.openDataOutputStream();
dataOS.flush();
dataOS.close();
DataInputStream dataIS = (DataInputStream) httpConn
.openDataInputStream();
int ch;
sb = new StringBuffer();
System.out.println("%%%% Me here 4 sb is ::" + sb.toString());
while ((ch = dataIS.read()) != -1) {
sb.append((char) ch);
}
// Respeonse
// -------------------------------------------------------------
System.out.println("sb.toString()::" + sb.toString());
String responseData = sb.toString();
dataIS.close();
httpConn.close();
一段時間連接斷開後後關閉。什麼是錯的,任何一個可以幫助
1)。在多少次連接將關閉......? 2)。當連接將斷開「發送數據」或「其他」...? – 2011-12-30 07:36:00
我在我的應用程序中使用web服務。我能夠登錄到應用程序,並從所有用戶數據的形式獲取web服務的響應,然後之後得到斷開連接後,當我發送請求其顯示請求超時 – happy 2011-12-30 11:56:49
任何進度。 ?? – 2011-12-30 13:08:23