Re: using select() without blocking the runloop

James Walker

On Nov 24, 2017, at 12:57 AM, Gerriet M. Denkmann <g@...> wrote:

I need to do select() with a rather large timeout value (several minutes).

So in order not to block the runLoop / mainThread I tried:

dispatch_queue_t myQueue = dispatch_get_global_queue( QOS_CLASS_BACKGROUND, 0 );
dispatch_async( myQueue, ^void(void)
selectResult = select(one_highest_fd, p_read_fds, p_write_fds, p_except_fds, ptv);
selectErrno = errno;

But I get EINVAL = Invalid argument.
Seems like file descriptors are thread specific.

How to do an asynchronous select() ?
I don’t think file descriptors are thread specific.

Most of your parameters to select are pointers. But what do they point to? If they point to structures on the stack, that would be bad, because those structures will be gone by the time the select runs.

Join to automatically receive all group messages.