try {
while (true) {
Socket us = servSock.accept();
String hostName = us.getInetAddress().getHostName();
System.out.println("Accepted from " + hostName);
ChatHandler cl = new ChatHandler(us, hostName);
synchronized (clients) {
clients.add(cl);
cl.start();
if (clients.size() == 1)
cl.send(CHATMASTER_ID, "Welcome! you're the first one here");
else {
cl.send(CHATMASTER_ID, "Welcome! you're the latest of " +
clients.size() + " users.");
}
}
}
} catch(IOException e) {
log("IO Exception in runServer: " + e);
System.exit(0);
}