System.out.println("客户端退出。");前面打印一下异常信息

解决方案 »

  1.   

    没错啊?我怎么试了下没报错...就是发一次之后断开了然后才会报connect的错误啊
      

  2.   

    有错误,你试一下启3,4个以上的Client端,关闭其中的一个其它的就会出错。但是保留注释行就能正常运行,就是不明白为什么dos不能关闭...
      

  3.   

    dos 是从socket -> OutputStream 你关闭了dos,间接的会影响 socket http://stackoverflow.com/questions/8890303/behavior-of-java-sockets-when-closing-output-stream
    from the description above, we know closing the returned OutputStream will close the associated socket.
      

  4.   

    不好意思啊还有地方不理解,如果Server端和Client端各自有指向对方Socket的dis和dos,那么Server的dos和Client的dis是一条线路吗,删除会互相影响Socket吗?