Re: CSocket, best way to wait for a reply?
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Sat, 09 Apr 2005 13:08:51 -0400
Been there, done that. Actually, didn't do that. The failure I mentioned earlier was
someone trying to implement this. It was a first-order total disaster. I had looked at a
few lines of code and said "under load, you lose packets, you send the wrong response to a
client, and eventually the whole system locks up". I said this by looking at ONE SCREENFUL
of their code, which had at least six major design errors in it, and it took me under a
minute to arrive at this conclusion. They had tried to retrofit asynchronous sockets into
a synchronous-socket program, and done it so badly it was unbelievable.
WIshing something would exist, when that something works in direct contravention to common
sense, isn't productive. As soon as you stop thinking that everything has to be
synchronous, your life gets easier.
Note that most windows functions are synchronous because there is not actually any
significant delay. And note that those which can have delay, such as I/O, actually have
asynchronous models for very good reasons. Most of us don't notice when our ReadFile takes
an extra 10ms because a head seek is involved, but if you are trying to process 100K TPM
(transactions per minute) you can't live with those 10ms delays. In networking, delays of
tens of seconds can be expected. Timeouts consequently need to be very large (the extreme
case is DNS resolution, which can take up to 70 seconds).
joe
On Fri, 08 Apr 2005 15:55:07 GMT, "AliR" <AliR@xxxxxxxxxxxxxxxx> wrote:
>I have a question, Isn't the majority of windows functions synchronous in
>nature? You ask the system to do something by calling a function and when
>the function returns it's done!
>
>Why can't there be a function that uses CAsyncSocket to do some kinda
>communication that does not return until there is a response or a timeout is
>reached?
>
>AliR.
>
>"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> wrote in message
>news:O61IkODPFHA.4000@xxxxxxxxxxxxxxxxxxxxxxx
>> simon wrote:
>> >>Did you remove all the unnecessary message looping? I have several
>> >>applications that work flawlessly using CAsyncSocket the way it was
>> >>designed to be used (i.e. by simply overriding the virtual functions).
>> >>
>> >
>> >
>> > I have to an extent, the client still waits for a reply from the server
>but
>> > does not block the whole system anymore.
>> > ideally I would remove the need for waiting for a reply within the same
>> > function, but that would mean a lot of re-engineering.
>> >
>> > I wish there was a simple. safe, way to send/receive data between
>sockets in
>> > one call.
>> > If I 'ask' a question to the server how else would I wait for my reply.
>> >
>> > Simon
>>
>> I answered that earlier: If you let the MFC message pump operate
>> normally then your OnReceive override will be called when a reply comes
>> in from the server. It is a message handler: If you get a mouse click a
>> message comes in; If you get data from the server OnReceive is called.
>>
>> --
>> Scott McPhillips [VC++ MVP]
>>
>
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- CSocket, best way to wait for a reply?
- From: simon
- Re: CSocket, best way to wait for a reply?
- From: Joseph M . Newcomer
- Re: CSocket, best way to wait for a reply?
- From: simon
- Re: CSocket, best way to wait for a reply?
- From: Scott McPhillips [MVP]
- Re: CSocket, best way to wait for a reply?
- From: simon
- Re: CSocket, best way to wait for a reply?
- From: Scott McPhillips [MVP]
- Re: CSocket, best way to wait for a reply?
- From: AliR
- CSocket, best way to wait for a reply?
- Prev by Date: Re: CSocket, best way to wait for a reply?
- Next by Date: Re: CSocket, best way to wait for a reply?
- Previous by thread: Re: CSocket, best way to wait for a reply?
- Next by thread: Re: CSocket, best way to wait for a reply?
- Index(es):
Relevant Pages
|