change select() to poll() in waiting for a socket to be readable

select()/FD_ISSET() does not work for file descriptor larger than 1023.