public class Server {
@SuppressWarnings("unused")
public static void main(String[] args) {
System.out.println("服务器已经启动");
System.out.println("等待客户端连接");
int i=0;
try {
ServerSocket serverSocket=new ServerSocket(8888);
while(true){
Socket socket=serverSocket.accept();
InetAddress inetAddress=socket.getInetAddress();
// i++;
System.out.println("当前用户的IP地址"+inetAddress.getHostAddress()+",用户的主机名字:"+inetAddress.getHostName());
MyThread myThread=new MyThread(socket);
myThread.start();
//System.out.println("当前在线人数:"+i);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
1