use nonblocking sockets to prevent hanging