-2
我使用下面的代碼爲tcp連接tcp連接來獲得IMEI
public String connectToservertocheckuserstatus(String phonurl, String imei)
throws IOException {
URL url = new URL(phonurl);
Socket sock=new Socket("localhost", 123);
sock.connect(url);
//con.setDoInput(true);
// Allow Outputs
//con.setDoOutput(true);
//con.connect();
BufferedWriter writer = null;
writer = new BufferedWriter(new OutputStreamWriter(
sock.getOutputStream(), "UTF-8"));
// give server your all parameters and values (replace param1 with you
// param1 name and value with your one's)
writer.write("imei=" + imei);
writer.flush();
String responseString = "";
BufferedReader reader = null;
reader = new BufferedReader(new InputStreamReader(sock.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
responseString = responseString.concat(line);
}
sock.close();
return responseString;
}
但我發現了問題。我的conncetion字符串是:
String imeiurl = appConstants.ip + "/tel_dir/imei.php";
但它不工作。你能告訴我它有什麼問題嗎?
請發佈您正面臨的問題和logcat錯誤轉儲的詳細信息。 – 2012-03-02 13:26:19
sock.connect(URL)甚至沒有編譯。你真正的代碼是什麼? – EJP 2012-03-03 01:34:07