套接字异常:连接重置

时间:2014-10-13 11:35:35

标签: java sockets

    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();

See Image

我如何解决它。它在eclipse和jdk上给出了相同的错误..

1 个答案:

答案 0 :(得分:2)

WHOIS请求被\r\n终止。您的请求不合法,因此对等方正在关闭连接,或者甚至可能重置连接。或者也许该服务器只是无法为您的客户提供服务。

相关问题