Hey,
How can I terminate a server after some number of connections (don't want it to keep on running forever). I've written in it C, using the select system call, and an array to store the connections made in..
while (1) {
FD_ZERO(&rdset);
FD_SET(clients[fd], &rdset);
( select(max+1, &rdset, NULL, NULL, NULL) <= 0){
continue;
}
for (i = 0 ; clients[i] <= max; i++) {
if (FD_ISSET(clients[i], &rdset)) {
if (clients[i] == fd) {
length = sizeof (client_struct);
new_fd = accept(server_soc, (struct sockaddr *) &client_struct, &length);
clients[i] = new_fd;
FD_SET(clients[i], &rdset);
}
else {
// Processing data
}
}
}
}