Operating System - HP-UX
1832143 Members
2946 Online
110038 Solutions
New Discussion

Re: Setting timeout for client program

 
Abdul Majeed Lardhi
Regular Advisor

Setting timeout for client program

Hi,
I am facing a problem that my client program and server program wainting in recv statment, I came to this point due to the poor design of the server program ( the code not available ),
Any one can helping me to set the timeout of the socket (in recv mode) ?
I've not see any socket option ( setsockopt ) for that purpose !!
Thanks in advance

Majeed Lardhi
2 REPLIES 2
Steven Gillard_2
Honored Contributor

Re: Setting timeout for client program

If you don't have the code then there's probably not a lot you can do - recv() by default in blocking mode will wait as long as the connection is alive.

The normal way to enforce a timeout on a recv() call is to put the socket in non-blocking mode with fcntl() or ioctl(), then use select() with the appropriate timeout argument to determine when the socket is ready for recv'ing.

See this page for loads more info on sockets programming:

http://www.ibrado.com/sock-faq/

Regards,
Steve
Abdul Majeed Lardhi
Regular Advisor

Re: Setting timeout for client program

Hi Steven,

I dont have the code of the server program !!!

I expect there socket option to set instead of usinf select

advise pls.

regards