我使用下面的code为TCP连接
I am using the following code for the tcp connection
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字符串是:
But I'm getting problems. My conncetion string is:
String imeiurl = appConstants.ip + "/tel_dir/imei.php";
但它不工作。你能告诉我什么是它存在的问题?
But its not working. Can you tell me whats the problem with it?
另外,请避免保存的IMEI。这不是安全的,这是一个隐私问题。你想要吗 跟踪单个设备?如果是这样,使用用户名/密码认证。
Also, please avoid saving the IMEI. It's not secure, and it's a privacy issue. Do you want to track individual devices? If so, use user/password authentication.
另外,IMEI是手机的用户的特征,而不是。当用户丢失手机或者已经被盗怎么办?这有点像说,你会被存储在用户的计算机的序列号跟踪从网站的计算机用户。
Also, the IMEI is a feature of the phone, not the user. What happens when the user loses the phone or has it stolen? It's rather like saying that you're going to track a computer user from a web site by storing the serial number from the user's computer.