• 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: NSConnection hostname
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSConnection hostname


  • Subject: Re: NSConnection hostname
  • From: Andreas Doerr <email@hidden>
  • Date: Thu, 21 Feb 2002 10:50:38 +0100

The problem now is that I need to connect to a computer other than the localHost, so I need a way to search for computers on the local network, that have an IP address but no hostname.

Could someone tell me how I go about searching for a DO server on a network,
and then using its IP address (since there are no host names) to make an NSConnection?

Search the archives of cocoa-dev and macosx-dev. There has been a lot of discussion about this issue and even sample code posted. You will have to create a NSConnection with a NSSocketPort and specify an IP address and a port number for both the server and the client.

Well, this works if you *know* the IP address and port number in advance. IMHO this is not a reasonable option in any real world application.

Usually you want to look up the IP address and port number of DO server using it's identifier. This is what NSSocketPortNameServer is intended for. Unfortunately, at least to my knowledge, NSSocketPortNameServer currently does not work.

If you try to register your DO server with a NSSocketPortNameServer the following way

NSSocketPort* sp = [[NSSocketPort alloc] initWithTCPPort:1235];
NSConnection* con = [NSConnection connectionWithReceivePort:sp sendPort:sp];
NSSocketPortNameServer* pns = [NSSocketPortNameServer sharedInstance];
unsigned short nameSvrPort = [ns defaultNameServerPortNumber];

[con registerName:@"svr" withNameServer:pns];

or alternatively

[pns registerPort:sp name:@"svr" nameServerPortNumber:nameSvrPort]

You will end up with a signal 13 (SIGPIPE) in both cases. Doing a port scan on the defaultNameServerPortNumber reveals no listening process. My guess is, that there is at present no "server" running actually implementing the port name server functionality (something like gdomap server in GNUstep). From my point of view something like this server should be started when the first instance of NSSocketPortNameServer is created.

Anyone any insight about this topic?

CU,
-Andreas
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: NSConnection hostname (From: "Rafael K. Kobylinski" <email@hidden>)

  • Prev by Date: Re: Name for '#' glyph.
  • Next by Date: Re: EOF replacement
  • Previous by thread: Re: NSConnection hostname
  • Next by thread: bug in drawPageBorderWithSize
  • Index(es):
    • Date
    • Thread