• 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: Example of DO without nil as Host?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Example of DO without nil as Host?


  • Subject: Re: Example of DO without nil as Host?
  • From: Craig Bakalian <email@hidden>
  • Date: Sat, 19 Apr 2003 06:09:37 -0400

Hi All,

Thanks to all that helped me on this thread. Most of my research was
done in the archives of this list, and I have programmed with sockets
in java before. I just thought it was going to be so, so, so simple in
Cocoa with [NSConnection rootProxyForConnectionWithRegisteredName:
host: ]. There is a book in front of me which makes this claim...
I do have success with the code below, for running on same machine,
127.0.0.1 which probably means this will work on a network of machines.
I am a bit worried about how to release and when to release the
allocation of the *port. My client is terminating without any release,
and the snip of code below leaves the *port unreleased after the
function ends. Should I autorelease it?


NSSocketPort *port = [[NSSocketPort alloc]
initRemoteWithTCPPort:8808 host: myHost]; //autorelease]
NSConnection *connection = [[NSConnection
connectionWithReceivePort:nil sendPort:port] retain];
server = [[connection rootProxy] retain];
[server setProtocolForProxy: @protocol(TestServerProtocol)];
[server addTestClient: self];

if(server == nil)
{
[questionView setString: @"Unable to connect to server. Please
use Host Configuration to set host."];
}
else
{
[questionView setString: @"Please enter your full name, select
a test, and press start. Good Luck!"];
}

Craig Bakalian
www.eThinkingCap.com


On Friday, April 18, 2003, at 06:25 PM, Douglas Davidson wrote:

>
> On Friday, April 18, 2003, at 2:31 PM, Craig Bakalian wrote:
>
>> I am thoroughly confused here. Is there an example of an
>> NSConnection
>> to get a vended object with out passing nil as the host out there in
>> documentation land. I can't find one.
>>
>> server = [[NSConnection rootProxyForConnectionWithRegisteredName:
>> @"testServer" host: [[NSHost currentHost]address] ]retain];
>>
>> Also, [[NSHost currentHost]address] us returning the standard
>> 127.0.0.1
>> for the local host. Yet, one would think that this would bounce in my
>> iMac and get the server named @"testServer", but it doesn't. Has
>> anyone out there used this NSConnection? Apple engineers?
>
> This is a frequently asked (and answered) question. The answer is
> that inter-machine DO requires the use of an NSPort subclass that
> supports it, which the default subclass does not. NSSocketPort is
> such a subclass, and examples have been circulated on this and other
> lists demonstrating its usage. In Jaguar the NSSocketPortNameServer
> is available, using Rendezvous for simple name service on the local
> network (see the Jaguar release notes).
>
> Douglas Davidson
_______________________________________________
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: Example of DO without nil as Host? (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Re: memory. and a lot of continual small object allocations and deallocations.
  • Next by Date: Re: Right (or cntl)-clicking a button
  • Previous by thread: Re: Example of DO without nil as Host?
  • Next by thread: Re: Example of DO without nil as Host?
  • Index(es):
    • Date
    • Thread