public static void main(String[] args)throws Exception{ServerSocket svSocket =null;//Vector threads 为ServerThread集合Vector threads = new Vector();//开始监System.out.println ("listening..."); try {//创建服务端套接口svSocket = new ServerSocket(5555);}catch (Exception ex) {System.out.println ("Server create ServerSocket failed!");return;} try{int nid = 0;//监听是否有端连接while(true){Socket socket = svSocket.accept();System.out.println ("accept a client");//创建一个新的ServerThreadServerThread st = new ServerThread(socket,threads);//为客户配一个ID号st.setID(nid );threads.add(st);new Thread(st).start();//向所广播有新客户端连接for(int i=0;i 追问这是什么-下面是更多关于泥巴潭的问答
发布于:2020-07-26 04:36
浏览了 60次
1
import java.net.*;import java.io.*;import java.util.*;public class ChatServer{
最佳贡献者