1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
void *sip_listn(void *arg);
int main()
{
//initializing exosip
int i=0;
TRACE_INITIALIZE (6, stdout);
i=eXosip_init();
if (i!=0) { fprintf (stderr, "eXosip_init FAILED!!!\n"); return -1; }
int port1=5060;
int port2=5070;
int port3=5080;
pthread_t thread1; // this is our thread identifier
pthread_t thread2; // this is our thread identifier
pthread_create(&thread1,NULL,&sip_listn,(void *) &port1);
pthread_create(&thread2,NULL,&sip_listn,(void *) &port2);
pthread_join(thread1,NULL);
pthread_join(thread2,NULL);
return 0;
}
void *sip_listn(void *arg)
{
int i;
int k;
int *port;
port = (int*) arg;
eXosip_event_t *event;
fprintf (stderr, "Opening port... p:%d\n",*port);
i = eXosip_listen_addr (IPPROTO_UDP, NULL, *port, AF_INET, 0);
if (i!=0)
{ eXosip_quit(); fprintf (stderr, "Could not initialize transport layer p:%d -> error: %d\n",*port,i); return NULL; }
else { fprintf (stderr, "Port is open p: %d\n",*port); }
fprintf (stderr, "\n SIP server -> Listening on port: %d\n",*port);
for (;;)
{
event = eXosip_event_wait (0, 50);
eXosip_lock();
eXosip_automatic_action ();
eXosip_unlock();
if (event == NULL)
{
;
printf ("\n Waiting for message: %d\n",*port);
} else {
//some code
}
|