Hi, I have been playing with pjnath. Things usually work fine if I use a large (e.g. > 50ms) timeout for the pj_ioqueue_poll function. However I don't want the thread to wait in pj_ioqueue_poll. If I reduce the timeout to 1-10ms the ICE negotiation fails (different error codes). The process_ function gets called in a loop over and over without interruption. Here is the code... void process_(uint32 maxMs) { pj_time_val maxTimeout = {0, 0}; maxTimeout.msec = maxMs; pj_time_val timeout = {0, 0}; timeout.sec = 0; timeout.msec = 0; pj_timer_heap_poll(_iceConfig->stun_cfg.timer_heap, &timeout); if (timeout.sec < 0 || timeout.msec < 0) { timeout.sec = 0; timeout.msec = 0; } else if (timeout.msec >= 1000) { timeout.msec = 999; } if (PJ_TIME_VAL_GT(timeout, maxTimeout)) { timeout = maxTimeout; } unsigned netEventCount = 0; int c = 0; do { c = pj_ioqueue_poll(_iceConfig->stun_cfg.ioqueue, &timeout); if (c < 0) { pj_status_t err = pj_get_netos_error(); pj_thread_sleep(PJ_TIME_VAL_MSEC(timeout)); return; } else if (c == 0) { break; } else { netEventCount += c; timeout.sec = 0; timeout.msec = 0; } } while (c > 0 && netEventCount < PJSIP_MAX_NET_EVENTS); return; } -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20130716/539a51cc/attachment-0001.html>