Quote:
Originally posted by krivi
Please help me...
i have problem with connect().In some situations my program don't respond for long time period,because server dont respond.How to set function connect() to conecting just 5 seconds and after that exit...which function to use for timing?
|
This isn't so much a sockets problem as an IPC problem. You need to use the alarm(2) system call to send your program a SIGALRM signal in a given number of seconds. Set up a signal handler with sigaction() to catch the signal and inform the user that the server is crapped-out.
Use alarm once before the connect call specifying the number of seconds and once after the connect call sending it 0 to reset the previous alarm.
I know this was very terse, but it's all in the man pages or online somewhere. Have fun.