• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Orderly disconnecting using PowerPlant networking classes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Orderly disconnecting using PowerPlant networking classes


  • Subject: Re: Orderly disconnecting using PowerPlant networking classes
  • From: "Andy Cave" <email@hidden>
  • Date: Tue, 26 Oct 2004 09:40:53 +0100

Hi Dave.
 
Is the client/server your code? Below it states that "you send a disconnect message and then sends orderly disconnect". If so then this is wrong - you should send just an orderly disconnect then 'wait' for the reply and close the endpoint. I think your code should go something like (on the receiving side):
 
if (abort)
  endpoint->Disconnect();
else {
  endpoint->SendDisconnect();
 
  do {
    char buffer[1024];
    int bytes = sizeof(buffer);
    try {
      // Read Data and ignore until get disconnect.
      UInt32 ioDataSize = bytes;
      Boolean outExpediated;
      endpoint->ReceiveData(buffer, ioDataSize, outExpediated, 1);
    }
    catch (LException exception)
    {
      if (exception.GetErrorCode() == Disconnect_Error ||
          exception.GetErrorCode() == OrderlyDisconnect_Error)
        break;
    }
    catch (...) {}
    LThread::Yield();
  } while (true);
}
 
endpoint->Unbind();
 
delete endpoint;
 
Andy.
 
----- Original Message -----
From: "Dave Rehring" <email@hidden>
To: "macnetworkprog" <email@hidden>
Sent: Tuesday, October 26, 2004 3:09 AM
Subject: Orderly disconnecting using PowerPlant networking classes

> 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
>
>
>
 _______________________________________________
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

  • Follow-Ups:
    • Re: Orderly disconnecting using PowerPlant networking classes
      • From: Dave Rehring <email@hidden>
References: 
 >Orderly disconnecting using PowerPlant networking classes (From: Dave Rehring <email@hidden>)

  • Prev by Date: Orderly disconnecting using PowerPlant networking classes
  • Next by Date: Very poor PPP interface performance
  • Previous by thread: Orderly disconnecting using PowerPlant networking classes
  • Next by thread: Re: Orderly disconnecting using PowerPlant networking classes
  • Index(es):
    • Date
    • Thread