problem with SIGALRM
I have some problem with the SIGALRM. I have a multithreaded program in which each thread contains a object which implements a timed tcpconnect function as shown below:
static void connect_alarm(int signo)
cout<<"\nConnect_alarm .... .. Time out connect ...............\n";
typedef void (*sigfunc)(int);
int TimedConnect(int sockfd,struct sockaddr *remAddr,socklen_t len,int sec)
sigf = signal(SIGALRM,connect_alarm);
cout<<"\nError setting alarm.\n";
// pause(); for testing offline!!
When I run the program it works fine for some time and then there will be no timeout at all.Sometimes it display "Alarm Clock" and exits the program.
Here multiple threads are running simultaneously. I even tried it with a single thread, it didn't work. What is the wrong? This is the main part of my program.Please help!!