I had made an application which i used the ppp to send data on the portal via gprs .


After using this application continusly this starts evolving the the connect script failed error and i dont know the reson of this connect script failed and after restrart machine then it starts working again and after 2 ,3 transaction it starts giving same error so help me and tell me the conditions where this connect script failed error comes.

Please help me in this situation.
Code:
int ppp_open()
{
int fd9,i;
pthread_t thread3;


printf("PPP starting\n");
system("rm -f /var/run/ppp.link");
perror("system");
system("/etc/ppp/dialout&");
perror("dialout");
perror("system");
printf("PPP open\n");
sleep(6);
i=0;
pthread_create(&thread3, NULL,(void *)&display_senddata,(void *)0);    
while(i<20)
     {  
	    fd9 = open("/var/run/ppp.link",O_RDONLY);
		perror("open");
        printf("fD9=%d\n",fd9);
        if (fd9 > 0)
          {
           close(fd9);
	       pthread_join(thread3, NULL);
           break;
          }
        sleep(1);
        i++;
     }
  if(i>=20)
  { 
printf("PPP Closed \n");
lk_dispclr();
lk_disptext(1,0,"PPP FAILED",0);
lk_disptext(5,0,"Press any key",0);
printf("PPP failed\n");
lk_getkey();
ppp_close();
return -1;
  }
 printf("PPP Connected \n");
 lk_dispclr();
 lk_disptext(1,0,"PPP Connected",0);
 sleep(2);
 pthread_exit(NULL);
 return 0;

}