From: Erik Willsey Sent: Tuesday, September 19, 2000 6:04 PM To: lsellers Subject: RE: CFX_TCPClient Bug I have found 4 bugs within your code regarding the WAITFORRECVDATA tag. Request.cpp - Line 334: You have: WaitForRecvData( s, atoi(vWaitForRecvData)*1000); Should Be: WaitForRecvData( s, atoi(vWaitForRecvData)); You already specify that the parameter is in seconds, multiplying by 1000 greatly offsets the time. You may have been trying to set milliseconds; which in that case, this line is not wrong, but there is misdocumentation in the guidelines. -------------------------------------------------------------------------------- Request.cpp - Begin @ line 234 You have: tv.tv_sec=0; tv.tv_usec=200; Should be: tv.tv_sec=secs; tv.tv_usec=0; Again, this depends on whether your original intention was to have seconds or milliseconds. However, either way, the parameter for the time was not being used. Add that into the next bug, and an infinite loop is created. -------------------------------------------------------------------------------- Request.cpp - Begin @ line 240 You have: while( nosocks == 0 ) { FD_ZERO(&readfds); FD_SET(sock,&readfds); nosocks=select(FD_SETSIZE,&readfds,NULL,NULL,&tv); } Should be: FD_ZERO(&readfds); FD_SET(sock,&readfds); nosocks=select(FD_SETSIZE,&readfds,NULL,NULL,&tv); Reason: select() will return 0 when the time has elasped (it will also immediately return zero if no time has passed). This means that if no data is ever received from the server, an infinite loop is created (well at least until the socket is closed by host or node). By simply removing the while loop, this bug is taken care of. -------------------------------------------------------------------------------- Request.cpp - Begin @ line 247 The remainder of that method should reside within an if statement checking that "nosocks" is not zero. "nosocks" will only be zero if the time elapsed. By jumping into the while loop retrieving the data, another infinite loop is created, because recv() will always return 0 if there is no data in the socket's buffer. I hope this helps you some. You've written a great tag. Thanks, Erik Willsey Blitz Programming