日期:2014-05-20  浏览次数:20997 次

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