in my game i need to check for recieving data from any of the sockets (clients) connected. the clients that are connected are saved to an array. is there a way to check for recieving from any of the clients connected? i have tried a for loop for all of the clients/sockets connected and checked for that but it doesnt seem to work. heres my for loop
while (true) {
try {
for (Socket client : Server.clients) {
Server.in = new DataInputStream(client.getInputStream());
System.out.println("recieving information...");
String input = Client.in.readUTF();
Server.out = new DataOutputStream(client.getOutputStream());
Server.out.writeUTF("connected");
send(input);
}
} catch (Exception e) {
}
}
but i think it is only checking for one client at a time. also it doesnt help that i could be sending data wrong (or other error) so its hard to find the problem. thanks.