Changed SOL_IP to more-portable IPPROTO_IP
check fd < FD_SETSIZE