sockets

J

Jose

How do I put a timeout in the method listes in a socket to be closed
in 30 seconds? thanks!!
 
B

Ben Voigt [C++ MVP]

Peter Duniho said:
If you search this newsgroup for past discussions involving "socket" and
"timeout", you'll see the answers that have been posted previously.

The short version is: set a timer and close the socket after the desired
timeout occurs.

Or use BeginXYZ version of the function along with WaitHandle.WaitAny and a
TimeSpan. Then you can pass in other WaitHandle objects at the same time,
like a cancel ManualResetEvent (which could even be set from a different
process). Of course you'll still need to close the socket if the operation
didn't finish in time / user requested cancel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top