Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSocket timeout 1

Status
Not open for further replies.

smpaul

Programmer
Nov 13, 2002
7
GB
I am using CSocket to enable a Client and Server to talk to each other. The server blocks on the receive in its own thread, no problem there.

The Client sends to the server but then needs an ACK / NACK from the server to indicate that the message got through OK and that the message was valid. I do not want the client to continue until either the ACK / NACK is received from the server OR the blocking receive times out.

The problem is setting the CSocket::Receive to timeout, as this is a CSocket blocking socket it will not continue until it recieves something from the server, I would like it to timeout and default a NACK allowing the Client to take the appropriate action for a failed send.

I considered the CAsyncSocket for the Client and a while loop to simualte the time out, but I dont think that this is very efficient or the correct way to go.

Any ideas?
Thanks
smpaul
 
See Q138692 in MSDN title HOWTO: Configure a Time-Out on a CSocket Operation. Sample code is too long (not a huge) then I can't copy it here, sorry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top