当前位置: 代码迷 >> Java相关 >> java.net.SocketException: Connection reset异常
  详细解决方案

java.net.SocketException: Connection reset异常

热度:379   发布时间:2016-04-22 21:56:17.0
java.net.SocketException: Connection reset错误
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:189)
        at java.net.SocketInputStream.read(SocketInputStream.java:121)
        at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
        at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
        at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
        at java.io.InputStreamReader.read(InputStreamReader.java:184)
        at java.io.BufferedReader.fill(BufferedReader.java:154)
        at java.io.BufferedReader.readLine(BufferedReader.java:317)
        at java.io.BufferedReader.readLine(BufferedReader.java:382)
        at MyClient.doSocket(MyClient.java:41)
        at MyClient.main(MyClient.java:60)
我向一个指定IP发送报文出现的错误
public class MyClient {  
  
    public static void doSocket()throws UnknownHostExceptionIOException {  
          
        try {  
            Socket socket=new Socket("127.169.0.0",8888);  
            BufferedReader sysin=new BufferedReader(new InputStreamReader(System.in));  
            PrintWriter socket_os=new PrintWriter(socket.getOutputStream());  
           BufferedReader socket_is=new BufferedReader(new InputStreamReader(socket.getInputStream()));  
            String readline;  
            System.out.print("**Client:");  
            readline=sysin.readLine();   
            System.out.println("");  
            while(!readline.equals("bye")){  
                socket_os.println(readline);  
                socket_os.flush();  
                System.out.println("**Server:"+socket_is.readLine());  
                System.out.print("**Client:");  
                readline=sysin.readLine();   
                System.out.println("");  
            }  
            socket_os.close();  
  相关解决方案