这个是正常的。
你得加一个finally:主题逻辑像这样子:
try {  ServerSocket server = new ServerSocket(5776);  while (true) {    Socket connection = server.accept( );    try {      Writer out        = new OutputStreamWriter(connection.getOutputStream( ));      out.write("You've connected to this server. Bye-bye now.\r\n");       out.flush( );             connection.close( );   }   catch (IOException ex) {     // This tends to be a transitory error for this one connection;     // e.g. the client broke the connection early. Consequently,     // you don't want to break the loop or print an error message.     // However, you might choose to log this exception in an error log.   }   finally {     // Guarantee that sockets are closed when complete.      try {       if (connection != null) connection.close( );     }     catch (IOException ex) {}   }}catch (IOException ex) {  System.err.println(ex);}