代码:
#ifndef OSIP_MONOTHREAD
if (excontext->j_thread == NULL) {
excontext->j_thread = (void *) osip_thread_create (20000, _eXosip_thread, excontext);
if (excontext->j_thread == NULL) {
OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot start thread!\n"));
return OSIP_UNDEFINED_ERROR;
}
}
#endif
说明:当定义该宏,说明不单独创建线程,进行SIP报文内容的接收
#ifndef OSIP_MONOTHREAD
void *
_eXosip_thread (void *arg)
{
struct eXosip_t *excontext = (struct eXosip_t *) arg;
int i;
while (excontext->j_stop_ua == 0) {
i = eXosip_execute (excontext);
if (i == -2000)
osip_thread_exit ();
}
osip_thread_exit ();
return NULL;
}
eXosip_execute函数主要是调用select函数进行数据的接收,最外层的while是不断等待接收