gpt4 book ai didi

java - DEBUG/SntpClient(70) : request time failed: java.net.SocketException:Android 上的协议(protocol)不支持地址族

转载 作者:行者123 更新时间:2023-11-29 09:20:51 25 4
gpt4 key购买 nike

我创建这样的代码:

try {
int ct_id;
String ct_name;
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://10.0.2.2/update.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
Log.e("log_tag", "Error in http connection"+e.toString());
}
//convert response to string
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
sb = new StringBuilder();
sb.append(reader.readLine() + "\n");
String line="0";
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result=sb.toString();
}catch(Exception e){
Log.e("log_tag", "Error converting result "+e.toString());
}
//paring data
int max = 0;
try{
jArray = new JSONArray(result);
JSONObject json_data=null;
for(int i=0;i<jArray.length();i++){
json_data = jArray.getJSONObject(i);
ct_id=json_data.getInt("max(id)");
ct_name=json_data.getString("date");
max = ct_id;
}
}
catch(JSONException e1){

} catch (ParseException e1) {
e1.printStackTrace();
}

但是当我调试的时候出现了:

07-03 08:50:42.657: DEBUG/SntpClient(70): request time failed: java.net.SocketException: Address family not supported by protocol

这是什么意思?以及如何解决?

最佳答案

这看起来像一个本地 url,你确定你的 apache 在 80 端口上运行吗?您可以尝试访问此网址吗 http://10.0.2.2/update.php在桌面浏览器中,你看得正确吗?通常仅当套接字无法与服务器建立连接时才会出现此错误。

关于java - DEBUG/SntpClient(70) : request time failed: java.net.SocketException:Android 上的协议(protocol)不支持地址族,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6561846/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com