<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2912" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>HI All</FONT></DIV>
<DIV><FONT face=Arial size=2>I am receiving one error
BasicTaskScheduler::SingleStep() function</FONT></DIV>
<DIV><FONT face=Arial size=2>The error is
--> perror("BasicTaskScheduler::SingleStep(): select()
fails");<BR></FONT></DIV>
<DIV><FONT face=Arial
size=2>/////////////////////////////////////////////////////////////////////////////////////////</FONT></DIV>
<DIV><FONT face=Arial size=2>void BasicTaskScheduler::SingleStep(unsigned
maxDelayTime) <BR>{<BR> fd_set readSet = fReadSet; // make a copy for this
select() call<BR> <BR> DelayInterval const& timeToDelay =
fDelayQueue.timeToNextAlarm();<BR> struct timeval
tv_timeToDelay;<BR> tv_timeToDelay.tv_sec =
timeToDelay.seconds();<BR> tv_timeToDelay.tv_usec =
timeToDelay.useconds();<BR> // Very large "tv_sec" values cause select()
to fail.<BR> // Don't make it any larger than 1 million seconds (11.5
days)<BR> const long MAX_TV_SEC = MILLION;<BR> if
(tv_timeToDelay.tv_sec > MAX_TV_SEC)<BR> {<BR>
tv_timeToDelay.tv_sec = MAX_TV_SEC;<BR> }<BR> // Also check our
"maxDelayTime" parameter (if it's > 0):<BR> if (maxDelayTime > 0
&&<BR> (tv_timeToDelay.tv_sec >
(long)maxDelayTime/MILLION ||<BR>
(tv_timeToDelay.tv_sec == (long)maxDelayTime/MILLION
&&<BR> tv_timeToDelay.tv_usec >
(long)maxDelayTime%MILLION)))<BR> {<BR>
tv_timeToDelay.tv_sec = maxDelayTime/MILLION;<BR>
tv_timeToDelay.tv_usec = maxDelayTime%MILLION;<BR> }<BR> <BR>
int selectResult = select(fMaxNumSockets, &readSet, NULL,
NULL,<BR> &tv_timeToDelay);<BR> if
(selectResult < 0)<BR> {<BR>#if defined(__WIN32__) ||
defined(_WIN32)<BR> int err =
WSAGetLastError();<BR> // For some unknown reason, select() in
Windoze sometimes fails with WSAEINVAL if<BR> // it was called
with no entries set in "readSet". If this happens, ignore
it:<BR> if (err == WSAEINVAL && readSet.fd_count ==
0)<BR> {<BR> err = 0;<BR> // To stop this from
happening again, create a dummy readable socket:<BR> int
dummySocketNum = socket(AF_INET, SOCK_DGRAM,
0);<BR> FD_SET((unsigned)dummySocketNum,
&fReadSet);<BR> }<BR> if (err != 0)
<BR> {<BR>#else<BR> if (errno != EINTR && errno !=
EAGAIN) <BR> {<BR>#endif<BR> // Unexpected error -
treat this as fatal:<BR>#if
!defined(_WIN32_WCE)<BR> perror("BasicTaskScheduler::SingleStep():
select()
fails");<BR>#endif<BR> exit(0);<BR> }<BR> }<BR> <BR>
// Handle any delayed event that may have come due:<BR>
fDelayQueue.handleAlarm();<BR> <BR> // Call the handler function for
one readable socket:<BR> HandlerIterator iter(*fReadHandlers);<BR>
HandlerDescriptor* handler;<BR> // To ensure forward progress through the
handlers, begin past the last<BR> // socket number that we
handled:<BR> if (fLastHandledSocketNum >= 0) {<BR>
while ((handler = iter.next()) != NULL) {<BR> if
(handler->socketNum == fLastHandledSocketNum) break;<BR>
}<BR> if (handler == NULL) {<BR>
fLastHandledSocketNum = -1;<BR> iter.reset(); //
start from the beginning instead<BR> }<BR> }<BR>
while ((handler = iter.next()) != NULL) {<BR> if
(FD_ISSET(handler->socketNum, &readSet)
&&<BR> FD_ISSET(handler->socketNum, &fReadSet) /* sanity
check */ &&<BR> handler->handlerProc != NULL)
{<BR> fLastHandledSocketNum =
handler->socketNum;<BR>
// Note: we set "fLastHandledSocketNum" before calling the
handler,<BR> // in case
the handler calls "doEventLoop()" reentrantly.<BR>
(*handler->handlerProc)(handler->clientData,
SOCKET_READABLE);<BR> break;<BR>
}<BR> }<BR> if (handler == NULL && fLastHandledSocketNum
>= 0) {<BR> // We didn't call a handler, but we didn't get
to check all of them,<BR> // so try again from the
beginning:<BR> iter.reset();<BR> while
((handler = iter.next()) != NULL) {<BR> if
(FD_ISSET(handler->socketNum, &readSet) &&<BR>
FD_ISSET(handler->socketNum, &fReadSet) /* sanity check */
&&<BR> handler->handlerProc != NULL)
{<BR> fLastHandledSocketNum =
handler->socketNum;<BR> // Note: we set
"fLastHandledSocketNum" before calling the
handler,<BR>
// in case the handler calls "doEventLoop()"
reentrantly.<BR> (*handler->handlerProc)(handler->clientData,
SOCKET_READABLE);<BR> break;<BR>
}<BR> }<BR> if (handler == NULL)
fLastHandledSocketNum = -1;//because we didn't call a handler<BR>
}<BR>}<BR>//////////////////////////////////////////////////////////////////////////</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>with regards</FONT></DIV>
<DIV><FONT face=Arial size=2>rajesh</FONT></DIV></BODY></HTML>