fix #297: listen() may raise EBADF in case of many connections.