Select poging nummer 2
This commit is contained in:
parent
b11bfd7ea0
commit
de6a80253b
1 changed files with 1 additions and 2 deletions
|
@ -33,8 +33,6 @@ int main(){
|
||||||
|
|
||||||
fd_set pollset;
|
fd_set pollset;
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
//0 timeout - return immediately after select call
|
|
||||||
timeout.tv_sec = 1; timeout.tv_usec = 0;
|
|
||||||
|
|
||||||
//pollfd cinfd[1];
|
//pollfd cinfd[1];
|
||||||
//cinfd[0].fd = fileno(stdin);
|
//cinfd[0].fd = fileno(stdin);
|
||||||
|
@ -62,6 +60,7 @@ int main(){
|
||||||
while (std::cin.good() && std::cout.good()){
|
while (std::cin.good() && std::cout.good()){
|
||||||
FD_ZERO(&pollset);//clear the polling set
|
FD_ZERO(&pollset);//clear the polling set
|
||||||
FD_SET(fileno(stdin), &pollset);//add stdin to polling set
|
FD_SET(fileno(stdin), &pollset);//add stdin to polling set
|
||||||
|
timeout.tv_sec = 1; timeout.tv_usec = 0;
|
||||||
select(1, &pollset, 0, 0, &timeout);
|
select(1, &pollset, 0, 0, &timeout);
|
||||||
//only parse input from stdin if available or not yet init'ed
|
//only parse input from stdin if available or not yet init'ed
|
||||||
if ((!ready4data || (snd_cnt - snd_window_at >= snd_window_size)) && FD_ISSET(0, &pollset)){parseChunk();fflush(stdout);}
|
if ((!ready4data || (snd_cnt - snd_window_at >= snd_window_size)) && FD_ISSET(0, &pollset)){parseChunk();fflush(stdout);}
|
||||||
|
|
Loading…
Add table
Reference in a new issue