Linux Network Programming - custom timeout value for a TCP socket?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2008
Posts: 21
Reputation: axfv is an unknown quantity at this point 
Solved Threads: 3
axfv axfv is offline Offline
Newbie Poster

Linux Network Programming - custom timeout value for a TCP socket?

 
0
  #1
Dec 15th, 2008
From Beej's Guide to Network Programming:
How can I set a custom timeout value for a TCP or UDP socket?

It depends on your system. You might search the net for SO_RCVTIMEO and SO_SNDTIMEO (for use with setsockopt()) to see if your system supports such functionality.

The Linux man page suggests using alarm() or setitimer() as a substitute.
I'm interested in implementing a socket timeout using setitimer(), is there any sample code that does that? Thanks.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 33
Reputation: AlbertPi is an unknown quantity at this point 
Solved Threads: 2
AlbertPi AlbertPi is offline Offline
Light Poster

Re: Linux Network Programming - custom timeout value for a TCP socket?

 
0
  #2
Dec 15th, 2008
Socket client = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);
client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 5000);

So SocketOptionName has ReceiveTimeout/SendTimeout. Hope this will help you.


Albert
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC