Re: Timeout in a CSOCKET
You might give SO_RCVTIMEO a try. But I am not sure if it works or not.
I must say this not a nice way of socket programming (in the windows world
atleast).
One thing the CSocket or CAsyncSocket class will receive a message when
there is data to be received. So you shouldn't call Receive unless you get
that message. This way you can use a windows timer for the timeout.
One other thing, you should put the Receive call in a loop since you might
not get all of the data in the first Receive call.
AliR.
"Papastefanos Serafeim" <serafeim@otenet.gr> wrote in message
news:ea2sbq$pl9$1@ulysses.noc.ntua.gr...
I'm not sure if it's the correct newsgroup. If it's
not tell me and I'll repost to
microsoft.public.win32.programmer.networks.
I have written some code using CSocket, and
now there's a requirement for a timeout when
receiving data. So, I just want to do something
like
CSocket s;
s.Create();
s.Connect(...);
if(s.Recv(...) == ERROR_TIMEOUT ) {
got_a_timeout(...);
} else {
handle_data(...);
}
without changing many things in the already
written code. Is this possible or I have to use
another class ?
Thanks for any help !
--
Papastefanos Serafeim
serafeim@otenet.gr