我试图解决这个问题,但我没有得到一个好的解决方案。我刚刚用 httsurlconnection 打开了一个套接字并关闭了。但是,我打开的套接字没有关闭,并且套接字状态为 CLOSE_WAIT。这是我的代码和空气记录。我的代码有什么问题?
String https_url = "https://www.google.com";
URL url = new URL(https_url);
try {
con = (HttpsURLConnection) url.openConnection();
con.setRequestProperty("Connection", "close");
if(con!=null){
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
String input = br.readLine();
while(input.length() != 0)
{
input = br.readLine();
}
br.close();
con.disconnect();
}
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}