[ prev | next | up ]

Polling clients

[From your friendly TA]
> I have some questions about the helper code provided
> for polling clients.
> 
> while (select (max_sock + 1, &r, NULL, NULL, &timeout)) {
> 
> 1.  Should it be a 'if' instead of 'while'?
> 2.  Should it be max_sock+main_sock+1 instead of max_sock+1
> 
> and
> 
> max_sock = client[num_active_clients - 1].sock;
>
> what happens to max_sock when num_active_clients is 0?
1. The while seems ok. Remember, you are looping until select times out, which means that there was no new data in the past 100ms. At that point you send all the sound modifications that you've got, and then start again looking at your input. 2. As for max_sock, the code was written to provide you with the basic idea, but not with all the details. The assignment specifications have since been updated to clarify the calculation of this value.