Professional Web Applications Themes

Establishing DO connection to non-local machine - Mac Programming

Some time a go I wrote a few simple games in Cocoa as a learning excercise. Now I'm trying to use Distributed Objects to add a multi-player facet to these games, using a single game server process and multiple client processes. I'm able to form a connection correctly between a server and a client on the same machine, using server = [[NSConnection rootProxyForConnectionWithRegisteredName: "tjg_game_server" host: hostAddress] retain]; where hostAddress is either nil or an empty string. But when I try to use "172.25.19.100" (the address on my "server" machine, as displayed in SystemPrefs/Network), I can't make a connecttion; the server ...

  1. #1

    Default Establishing DO connection to non-local machine

    Some time a go I wrote a few simple games in Cocoa as a learning
    excercise. Now I'm trying to use Distributed Objects to add a
    multi-player facet to these games, using a single game server process
    and multiple client processes.

    I'm able to form a connection correctly between a server and a client on
    the same machine, using
    server = [[NSConnection rootProxyForConnectionWithRegisteredName:
    "tjg_game_server" host: hostAddress] retain];

    where hostAddress is either nil or an empty string. But when I try to
    use "172.25.19.100" (the address on my "server" machine, as displayed
    in SystemPrefs/Network), I can't make a connecttion; the server comes
    back as null. This failure happens even when I run the client process on
    the same machine as the server process! I know the address is correct,
    because ping succeeds using that address.

    Every example of rootProxyForConnectionWithRegisteredName:host: that I
    have been able to find on the web seems to use nil as the host. Well
    that works just fine, but I'd like to make a connection to a different
    computer!

    Is there some security setting somewhere that needs to be configured to
    allow vending of remote objects? Any suggestions for further
    investigation will be welcome; I'm pulling my hair out over this one...
    :-)


    --
    Tim Gogolin
    tgogolin Guest

  2. #2

    Default Re: Establishing DO connection to non-local machine

    In article <tgogolin-1AD49B.07113212072003hermes-ge0.rdc-kc.rr.com>,
    tgogolin <tgogolinmac.removethis.com> wrote:
    > Some time a go I wrote a few simple games in Cocoa as a learning
    > excercise. Now I'm trying to use Distributed Objects to add a
    > multi-player facet to these games, using a single game server process
    > and multiple client processes.
    >
    > I'm able to form a connection correctly between a server and a client on
    > the same machine, using
    > server = [[NSConnection rootProxyForConnectionWithRegisteredName:
    > "tjg_game_server" host: hostAddress] retain];
    >
    > where hostAddress is either nil or an empty string. But when I try to
    > use "172.25.19.100" (the address on my "server" machine, as displayed
    > in SystemPrefs/Network), I can't make a connecttion; the server comes
    > back as null. This failure happens even when I run the client process on
    > the same machine as the server process! I know the address is correct,
    > because ping succeeds using that address.
    >
    > Every example of rootProxyForConnectionWithRegisteredName:host: that I
    > have been able to find on the web seems to use nil as the host. Well
    > that works just fine, but I'd like to make a connection to a different
    > computer!
    By default, NSConnection uses NSPort, which uses Mach ports. Mach ports
    are machine-local; that is, they don't work over a network.

    But all is not lost. You can use NSSocketPorts instead of NSPorts with
    NSConnection, which gives you Distributed Objects running over TCP. You
    can't vend objects by name (at least not without using Rendezvous), but
    it works pretty well.

    Look at the bottom of:

    [url]http://www.cocoadev.com/index.pl?DistributedObjectsSampleCode[/url]

    There's some sample code which should get you started on how to make the
    connection. It's a bit more complex than the Mach port way, but it's not
    so bad.
    Michael Ash Guest

  3. #3

    Default Re: Establishing DO connection to non-local machine

    In article <mail-0039FF.13150212072003localhost>,
    Michael Ash <mailmikeash.com> wrote:
    > In article <tgogolin-1AD49B.07113212072003hermes-ge0.rdc-kc.rr.com>,
    > tgogolin <tgogolinmac.removethis.com> wrote:
    > > ...
    > > Every example of rootProxyForConnectionWithRegisteredName:host: that I
    > > have been able to find on the web seems to use nil as the host. Well
    > > that works just fine, but I'd like to make a connection to a different
    > > computer!
    >
    > By default, NSConnection uses NSPort, which uses Mach ports. Mach ports
    > are machine-local; that is, they don't work over a network.
    >
    > But all is not lost. You can use NSSocketPorts instead of NSPorts with
    > NSConnection, which gives you Distributed Objects running over TCP. You
    > can't vend objects by name (at least not without using Rendezvous), but
    > it works pretty well.
    >
    > Look at the bottom of:
    >
    > [url]http://www.cocoadev.com/index.pl?DistributedObjectsSampleCode[/url]
    >
    > There's some sample code which should get you started on how to make the
    > connection. It's a bit more complex than the Mach port way, but it's not
    > so bad.

    Thank you Michael, I've gotten the basics up and running after following
    that link. (And thank you too to Chris Kane if you happen to see this
    newsposting!)

    I have to say, I usually find the Cocoa APIs to be fairly self-evident
    when browsing the header files, but this has been an exception... Was
    there ever a time when rootProxyForConnectionWithRegisteredName:host:
    actually used the 'host' parameter? The current doentation seems
    misleading...

    --
    Tim Gogolin
    tgogolin Guest

  4. #4

    Default Re: Establishing DO connection to non-local machine

    In article <tgogolin-9137D5.20563212072003hermes-ge0.rdc-kc.rr.com>,
    tgogolin <tgogolinmac.removethis.com> wrote:
    > I have to say, I usually find the Cocoa APIs to be fairly self-evident
    > when browsing the header files, but this has been an exception... Was
    > there ever a time when rootProxyForConnectionWithRegisteredName:host:
    > actually used the 'host' parameter? The current doentation seems
    > misleading...
    I don't know for sure myself. But with my experience with old versions
    of Rhapsody and MacOS X Server and so on, I believe Mach messaging used
    to work across networks (at least on the local subnet) and for some
    reason doesn't anymore. Which would explain the method name. If anybody
    knows more than I do, please correct me.
    Michael Ash Guest

Similar Threads

  1. Establishing connection
    By J. Cliff Canipe in forum Macromedia Contribute Connection Administrtion
    Replies: 17
    Last Post: February 8th, 07:09 PM
  2. filecopy from remote machine to local machine
    By anu in forum PERL Modules
    Replies: 5
    Last Post: February 8th, 03:49 PM
  3. need help establishing connection with IIS
    By J Long in forum Coldfusion - Getting Started
    Replies: 2
    Last Post: February 18th, 03:04 PM
  4. Replies: 2
    Last Post: June 17th, 12:08 AM
  5. Replies: 1
    Last Post: June 26th, 09:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139