// Use select() to determine when data is waiting to be read
int metaPing_waitForEchoReply(SOCKET s, int waittime)
{
struct timeval Timeout;
fd_set readfds;
int nRet;
// untill I find a better way of killing this thread, only
// wait in periods of maximum 250ms. Better for menu responsiveness ;-)
if (waittime > 250) waittime = 250;
readfds.fd_count = 1;
readfds.fd_array[0] = s;
Timeout.tv_sec = waittime / 1000;
Timeout.tv_usec = waittime % 1000;
nRet=(select(1, &readfds, NULL, NULL, &Timeout));
return nRet;
}