using poll instead of select for platform portability