Re: server scenario - variables in the right spot?
- From: "David" <nospam@xxxxxxxxxx>
- Date: Thu, 7 Jun 2007 17:11:31 -0400
thanks Peter. I figured I wasn't using the async model correctly. I'm having
a hard time visualizing how the client-server conversation looks (in code)
when done as you suggest (without waithandles). Inevitably there is a
conversation in which one side can't take the next step until an answer is
received. So how is this 'wait' handled using asynch api as its supposed to
be used? I can grasp the beginAccept callback posting another beginAccept as
opposed to the loop structure I have in my example (in fact I think I'll
make that change), but as you put it, the 'connection-specific stuff with
sending and receiving', thats where I can't visualize the asynch structure,
other than how I did it (using waithandles)... it seems my head needs that
'control' or 'main' thread to keep things straight. For example, in some
cases my beginReceive callback posts another beginReceive until all data is
received, but its another thread that started that receive operation in the
first place and is waiting to do something with what is received... You
*are* suggesting I would not need that 'control' or 'main' thread approach
if using asych api better, right? what would that look like? no waithandles?
makes my brain twist in ways its not meant to.. hehe. :)
"Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx> wrote in message
news:op.ttkhez158jd0ej@xxxxxxxxxxxxxxxxxxxxxxx
On Thu, 07 Jun 2007 12:21:21 -0700, David <nospam@xxxxxxxxxx> wrote:
i think i just realized i'm an idiot. again.
For what it's worth, I've seen idiots around here, and you ain't it. :)
thanks.
[...] What happens when many
clients are being serviced at the same time? Will they all be using those
SAME AutoResetEvents and screwing each other up?
[...]
Well, the biggest issue I see is that you should not need the events at
all. Instead, for example, your AcceptCallback() method should post
another Socket.BeginAccept(). Likewise sending and receiving.
You are correct that there is some potential for interference between
clients (though actually, the accept case is probably okay...it's the
connection-specific stuff with sending and receiving where things get
messy), but that all is avoided if you take advantage of the inherent
threading model that the asynch API provides in the first place.
Pete
.
- Follow-Ups:
- Re: server scenario - variables in the right spot?
- From: Peter Duniho
- Re: server scenario - variables in the right spot?
- References:
- server scenario - variables in the right spot?
- From: David
- Re: server scenario - variables in the right spot?
- From: Peter Duniho
- server scenario - variables in the right spot?
- Prev by Date: Launch devenv.exe and open a web site?
- Next by Date: Re: compare two structs via ==
- Previous by thread: Re: server scenario - variables in the right spot?
- Next by thread: Re: server scenario - variables in the right spot?
- Index(es):
Relevant Pages
|