• 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: Using IP or hostname for NSConnections rootProxyForConnectionWithRegisteredName:host:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using IP or hostname for NSConnections rootProxyForConnectionWithRegisteredName:host:


  • Subject: Re: Using IP or hostname for NSConnections rootProxyForConnectionWithRegisteredName:host:
  • From: Chuck Fleming <email@hidden>
  • Date: Tue, 30 Mar 2004 08:50:55 -0800

Hi,

In NSSocketPort's initWithRemoteTCPPort:host: you should be able to use
an IP address. Typically you'll have a struct sockaddr * in your
hands and so just feed it to something like the following. The
returned string can be used for the host: parameter.

- (NSString *)hostForAddress:(struct sockaddr *)address
{
struct sockaddr_in *inAddress = (struct sockaddr_in *)address;
char asciiAddress[100];

inet_ntop(AF_INET, &(inAddress->sin_addr), asciiAddress,
sizeof(asciiAddress));
NSString *host = [[NSString alloc] initWithCString:asciiAddress];
return [host autorelease];
}

Chuck



On Mar 29, 2004, at 10:41 PM, Mark wrote:

> I'm surprised that I couldn't use an IP for the host parameter but your
> clues pointed me in the right direction. I'm connecting using IP now -
> albeit with a bit more lines of code.
>
> Thanks very much.
>
> -mark
>
> -----Original Message-----
> From: email@hidden
> [mailto:email@hidden] On Behalf Of Chuck Fleming
> Sent: Monday, March 29, 2004 1:54 PM
> To: Mark Walker
> Cc: email@hidden
> Subject: Re: Using IP or hostname for NSConnections
> rootProxyForConnectionWithRegisteredName:host:
>
> Hi,
>
> It sounds like your ultimate goal is to use DO between different
> machines.
> If that's the case, briefly here's what you'll need.
>
> On the server side:
> NSSocketPort's initWithTCPPort:
> followed by
> NSConnection's initWithReceivePort:sendPort:
>
> On the client side:
> NSSSocketPort's initWithRemoteTCPPort:host:
> followed by
> NSConnections's initWithReceivePort:sendPort:
>
> Chuck
>
>
> On Mar 28, 2004, at 9:18 PM, Mark Walker wrote:
>
>> I'm just beginning to work the distributed objects and I had great
>> initial success getting a vended object using the following
>> incantation:
>>
>> myServer = [[NSConnection
>> rootProxyForConnectionWithRegisteredName:myVendedObject
>> host:serverName] retain];
>>
>> Where myServer is of type id, myVendedObject is the name of the root
>> object set by the server. serverName is where I'm having the problem.
>>
>> When serverName is set to nil and my client is on the same machine as
>> the server everything works fine. If I set serverName to the IP
>> address of my machine it no longer works.
>>
>> All the examples I can find pass nil or @"" to the host parameter so I
>> have very little to go on to fix my problem.
>>
>> I also tried setting serverName to @"*" as suggested by some of the
>> googled results but I think that's specific to OpenStep (?)
>>
>> Any help would be appreciated.
>>
>> -mark
>> _______________________________________________
>> 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.
> _______________________________________________
> 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.
_______________________________________________
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.


  • Prev by Date: Why does this keep sending EXC_BAD_ACCESS
  • Next by Date: Re: Why does this keep sending EXC_BAD_ACCESS
  • Previous by thread: RE: Using IP or hostname for NSConnections rootProxyForConnectionWithRegisteredName:host:
  • Next by thread: Problem saving movie
  • Index(es):
    • Date
    • Thread