2025-11-05 02:10:56分类:人工智能阅读(95725) 
复制publicstaticvoid main(String[] args) throws IOException { ServerSocket ss = new ServerSocket(); ss.bind(new InetSocketAddress(Constant.HOST,什香
Constant.PORT)); int idx =0; while (true) { final Socket socket = ss.accept();//阻塞方法 new Thread(() -> { handle(socket); },"线程["+idx+"]" ).start(); } } staticvoid handle(Socket socket) { byte[] bytes = newbyte[1024]; try { String serverMsg = " server sss[ 线程:"+ Thread.currentThread().getName() +"]"; socket.getOutputStream().write(serverMsg.getBytes());//阻塞方法 socket.getOutputStream().flush(); } catch (Exception e) { e.printStackTrace(); } } 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.