以下代码重复运行,会出现服务器端口被占用,问:如何保证服务退出时端口被释放
ServerSocket server = new ServerSocket(6050);
Socket socket = server.accept();//接收客户端的请求
BufferedReader br = new BufferedReader( new InputStreamReader(socket.getInputStream()));
PrintStream ps = new PrintStream(socket.getOutputStream()); |
|