DistantObject, NSConnection, NSPortCoder Exception

  • I can not catch a "[NSPortCoder sendBeforeTime:sendReplyPort:] timed
    out" exception and gracefully handle it. I have a sample app in
    Master (server) mode on one computer and Slave (clients) mode on
    another machine(s) over a local network. I have the app randomly
    disconnect (turn client off) and/or crash (to simulate network
    problems) because I want the Master to be able to recover and re-
    connect after a problem.

    My app (in Master / server mode) crashes when this exception occurs.
    For those interested I have posted the sample app.

    http://homepage.mac.com/richsal/FileSharing7.html

    Thanks for any help,
    -Rich
  • On 9/11/07, Richard Salvatierra wrote:

    > I can not catch a "[NSPortCoder sendBeforeTime:sendReplyPort:]
    > timed out" exception and gracefully handle it. I have a sample app
    > in Master (server) mode on one computer and Slave (clients) mode on
    > another machine(s) over a local network. I have the app randomly
    > disconnect (turn client off) and/or crash (to simulate network
    > problems) because I want the Master to be able to recover and re-
    > connect after a problem.
    >
    > My app (in Master / server mode) crashes when this exception occurs.
    > For those interested I have posted the sample app.
    >
    > http://homepage.mac.com/richsal/FileSharing7.html
    >
    > Thanks for any help,
    > -Rich

    In order for the Master (as you call it) to recover and reconnect,
    register for NSPortDidBecomeInvalidNotification notification
    ( ([[NSNotificationCenter defaultCenter] addObserver: ...]) , it will
    inform you when the connection is lost.

    In addition when dispatching commands between the server and the
    client use @try {} @catch (id theException) {}, thus you will be
    informed if the DO communication fails and will prevent exceptions
    crash, there is no need to try catching NSPortCoder, set the send/
    reply timeout as desired.

    Guy
previous month september 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today