From 5c3ddab6570aec4f3cd3ce585a05dde9dd77dd90 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Sun, 7 Nov 2010 17:32:23 +0100 Subject: [PATCH] Polling poging 1 --- Connector_RTMP/main.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Connector_RTMP/main.cpp b/Connector_RTMP/main.cpp index 915fc6aa..c001d0aa 100644 --- a/Connector_RTMP/main.cpp +++ b/Connector_RTMP/main.cpp @@ -12,7 +12,7 @@ #include //needed for poll -//#include +#include //for connection to server #include "../sockets/SocketW.h" @@ -34,9 +34,9 @@ int main(){ fd_set pollset; struct timeval timeout; - //pollfd cinfd[1]; - //cinfd[0].fd = fileno(stdin); - //cinfd[0].events = POLLIN; + pollfd cinfd[1]; + cinfd[0].fd = fileno(stdin); + cinfd[0].events = POLLIN; //first timestamp set firsttime = getNowMS(); @@ -57,13 +57,14 @@ int main(){ #ifdef DEBUG fprintf(stderr, "Starting processing...\n"); #endif + int infile = fileno(stdin); while (std::cin.good() && std::cout.good()){ - FD_ZERO(&pollset);//clear the polling set - FD_SET(fileno(stdin), &pollset);//add stdin to polling set timeout.tv_sec = 1; timeout.tv_usec = 0; + FD_ZERO(&pollset);//clear the polling set + FD_SET(infile, &pollset);//add stdin to polling set select(1, &pollset, 0, 0, &timeout); //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)) && poll(cinfd, 1, 500)){parseChunk();fflush(stdout);} if (ready4data){ if (!inited){ //we are ready, connect the socket!