int n; socklen_t len; char mesg[MAXLINE]; char *hostname = "app-server"; for(;;) { len = clilen;
/* waiting for receive data */ n = recvfrom(sockfd, mesg, MAXLINE, 0, pcliaddr, &len); //mesg[n] ='/0'; printf("OK,i receave a data %s \n",mesg); snprintf(mesg,sizeof(mesg)," Authentication Required: %s\r\n" "Result: 1\r\n" "Call-ID: %s\r\n\r\n",hostname,hostname,hostname); /* sent data back to client */ sleep(2); n = sendto(sockfd, mesg, n, 0, pcliaddr, len);
s = (input_data *)malloc(input_data_len); if (NULL == s) { exit; } memset(s, 0, input_data_len); memcpy(s->inbuf,recvBuffer,sizeof(s->inbuf)); s->inlen = strlen(recvBuffer);
char *res; res = parse_result(s,"Call-ID"); if(res) printf("the result is %s \n",res); else printf("not found result ----- \n"); close(sock); return 0; }