现编这个就是个多线程服务器,只要在client不释放连接,服务器端的run里边写while(TRUE)循环,那么就可以长期连接。 class ConnectionThread extends Thread{ Socket client; int counter; public ConnectionThread(Socket cl,int c){ client = cl; counter= c; } @Override public void run() { try{ String destIP=client.getInetAddress().toString(); int destport =client.getPort(); PrintStream outstream=new PrintStream(client.getOutputStream()); DataInputStream instream=new DataInputStream(client.getInputStream()); String inline=instream.readLine(); }//try catch(IOException e){System.out.println(e);} }//run
现编这个就是
最新推荐文章于 2024-09-10 20:56:43 发布