discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSConnection, gdomap


From: Chris B. Vetter
Subject: NSConnection, gdomap
Date: Mon, 17 Nov 2003 11:41:11 -0800

Hi,

I'm not sure if this is a bug or feature, but I noticed the following:

If you initialize an NSConnection with each a receive port for NSHost
+localHost, then register a name, gdomap will still tell you that it
found the port on both, the actual IP of your host, and on localhost.
Example

  port = [NSSocketPort portWithNumber: 0
                               onHost: [NSHost localHost]
                         forceAddress: @"127.0.0.1"
                             listener: YES];

  con = [[NSConnection alloc] initWithReceivePort: port
                                         sendPort: nil];

  [con setRootObject: self];
  return [con registerName: @"Foobar"];

And on the console you get

  :0> gdomap -L Foobar
  Found Foobar on '64.95.194.245' port 12897
  :0> gdomap -L Foobar -M localhost
  Found Foobar on '127.0.0.1' port 12897

However...

  port = [NSSocketPort portWithNumber: 0
                               onHost: [NSHost localHost]
                         forceAddress: @"127.0.0.1"
                             listener: NO];

  con = [[NSConnection alloc] initWithReceivePort: nil
                                         sendPort: port];

  [con setRootObject: self];
  return [con registerName: @"Foobar"];

And on the console you get

  :0> gdomap -L Foobar
  Unable to find Foobar.
  :0> gdomap -L Foobar -M localhost
  Unable to find Foobar.

It does make sense, since there's no listening port, but, is this the
correct behaviour? Apparently, -registerName: returns NO here.

Now, if you use something like

  recv = [NSSocketPort portWithNumber: 0
                               onHost: [NSHost localHost]
                         forceAddress: @"127.0.0.1"
                             listener: YES];
  
  send = [NSSocketPort portWithNumber: 0
                               onHost: [NSHost localHost]
                         forceAddress: @"127.0.0.1"
                             listener: NO];

  con = [[NSConnection alloc] initWithReceivePort: recv
                                         sendPort: send];
  
  [con setRootObject: self];
  return [con registerName: @"Foobar"];

again gdomap will find 'Foobar' on both, IP and localhost, but only the
listening port.

Or maybe I'm making wrong assumptions?

What I'm trying to do is register a 'server' so a 'client' can find out
via NSConnection how (i.e. on which ports) to communicate (through a
socket) with the 'server'.

The problem is that the server has to use (a) socket(s) assigned by the
system (-portWithNumber: 0) and gdomap seemed to be the ideal solution
for how to let the client know on which port(s) the server is active.

Any suggestions are highly appreciated,

-- 
Chris




reply via email to

[Prev in Thread] Current Thread [Next in Thread]