diff --git a/main.c b/main.c index df8613c..149fb7c 100644 --- a/main.c +++ b/main.c @@ -25,8 +25,7 @@ int doFork = 0x1; int readSocks = 0x0; int t = 0x0; - fd_set readset; - fd_set faultset; + fd_set readSet; char data[1024]; struct timeval timeout = {30,0}; @@ -80,21 +79,18 @@ while (1) { - sGetConnections(&readset); - sGetConnections(&faultset); - readSocks = select(highSock+1,&readset,0x0,&faultset,&timeout); + + /* Build our readSet */ + sGetConnections(&readSet); + + readSocks = select(highSock+1,&readSet,0x0,0x0,&timeout); if (readSocks < 0) { perror("select failed"); exit(0x1); } - if (FD_ISSET(mySocket,&faultset) != 0x0) { - writeLog(0,"Socket Died!\n"); - sConnect(SERVER_HOST,SERVER_PORT); - } - - if (FD_ISSET(mySocket,&readset) != 0x0) { + if (FD_ISSET(mySocket,&readSet) != 0x0) { memset(&data,0x0,1024); if (sReadSocket(&data,1024) == -1) { writeLog(0,"Socket Died!\n"); @@ -106,7 +102,8 @@ } writeLog(0,"Got Data [%s]\n",data); } - + writeLog(0,"TimeOut\n"); + /* Flush the log file */ fflush(logFile); }