Orderly disconnecting using PowerPlant networking classes
Orderly disconnecting using PowerPlant networking classes
- Subject: Orderly disconnecting using PowerPlant networking classes
- From: Dave Rehring <email@hidden>
- Date: Mon, 25 Oct 2004 19:09:32 -0700
I'm using PP's threaded networking classes and am having trouble doing an
orderly disconnect.
Either the client or the server can initiate a disconnect and prior to
disconnecting, they normally will send a message indicating they are about
to disconnect.
Right now, a fair amount of the time I'll get
Server -> sends a disconnect message and then sends orderly disconnect
[using LOpenTptTCPEndpoint::SendDisconnect()]
Client -> receives disconnect message, then sends orderly disconnect [using
LOpenTptTCPEndpoint::SendDisconnect()]. By this time, client will also have
received the orderly disconnect, so it goes to the idle state as it has both
received and sent an orderly disconnect].
The server has two problems at this point:
1) Generally, there will be no data to receive, so my 'Run()' loop, which
is fairly similar to the default PP LAsyncProtocolThread::Run() function,
never exits, as there is never any data either to send or receive
2) To 'solve' 1, I added a case where if I sent a disconnect I would
a) repeatedly resume the PP networking thread from an idle timer
b) in the Run() loop, I would call mEndpoint->AcceptRemoteDisconnect();
in a try/catch block, and if it doesn't throw an exception, I exit the run
loop as I've received the disconnect
Doing 2 is ugly [to me anyway :-) ] and doesn't always work, as about 1/2
the time, the server won't receive the orderly disconnect.
This is still a classic application, so no suggestions to:
-port to CFNetworking
-port to sockets
;-)
Any ideas/thoughts on properly doing the orderly disconnect?
Later,
--
David Rehring Psychos do not explode when light hits
VP of Research and Development them, no matter how crazy they are...
Atimi Software, Inc.
www.atimi.com And totally insane guy!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden