Socket Soc=new Socket("whois.internic.net",43);//Creating a Socket.
InputStream In=Soc.getInputStream(); //Getting Input Stream
OutputStream Out=Soc.getOutputStream(); //Getting Output Stream
String Str="MHProfessional.com";
Out.write(Str.getBytes());
int c;
while((c=In.read())!= -1) { //this is line 11!..Commenting it out works fine.
System.out.print((char)c);
}
Soc.close();
如何解决。它在 eclipse 和 jdk 上给出相同的错误..
最佳答案
WHOIS
请求被 \r\n
终止。您的请求不合法,因此对等方正在关闭连接,甚至可能重置连接。或者该服务器可能不会为您的客户端提供服务。
关于java - 套接字异常: Connection Reset,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26339060/