Polling poging 4

This commit is contained in:
Thulinma 2010-11-07 17:50:25 +01:00
parent 8c0f42c6e7
commit f71a51cc1b

View file

@ -31,9 +31,6 @@ int main(){
unsigned int ftst; unsigned int ftst;
SWUnixSocket ss; SWUnixSocket ss;
fd_set pollset;
struct timeval timeout;
pollfd cinfd[1]; pollfd cinfd[1];
cinfd[0].fd = fileno(stdin); cinfd[0].fd = fileno(stdin);
cinfd[0].events = POLLIN; cinfd[0].events = POLLIN;
@ -58,9 +55,9 @@ int main(){
fprintf(stderr, "Starting processing...\n"); fprintf(stderr, "Starting processing...\n");
#endif #endif
int infile = fileno(stdin); int infile = fileno(stdin);
while (std::cin.good() && std::cout.good()){ while (!ferror(stdin) && !ferror(stdout)){
//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)) && poll(cinfd, 1, (signed int)500)){parseChunk();fflush(stdout);} if ((!ready4data || (snd_cnt - snd_window_at >= snd_window_size)) && poll(cinfd, 1, 100)){parseChunk();fflush(stdout);}
if (ready4data){ if (ready4data){
if (!inited){ if (!inited){
//we are ready, connect the socket! //we are ready, connect the socket!