Distributed Objects over a Network
Distributed Objects over a Network
- Subject: Distributed Objects over a Network
- From: Pierre-Loïc Raynaud <email@hidden>
- Date: Mon, 5 Aug 2002 15:36:44 +0200
I'm trying to write an application that uses DO over a network.
My application can behave either as a client or a server.
It has one textfields (recipient IP address) and two TextViews :
One used to type a message on the client side, the other one used
to display the received message on the server side.
All is working perfectly well, as long as I'm using 127.0.0.1 as
the recipient IP address.
I tried either the physical address of another machine running my
application, or event my own IP address. In both case, line AAAA
(see below) returns a nil pointer.
Any idea what i'm missing ?
TIA,
Pierre-Looc
From MyController:
--------------------------
- (void)awakeFromNib
{
NSSocketPort *port = [[NSSocketPort alloc] initWithTCPPort:9000];
NSConnection *connection = [[NSConnection alloc]
initWithReceivePort:port sendPort:nil];
[connection setRootObject:[[MyServer
alloc]initWithField:mDisplayer]];
}
- (IBAction)sendMessage:(id)sender
{
id server;
NSSocketPort *port = [[NSSocketPort alloc]
initRemoteWithTCPPort:9000 host:[mIP stringValue]]; /* AAAA :
returns nil when host is not 127.0.0.1 */
NSConnection *connection = [NSConnection
connectionWithReceivePort:nil sendPort:port];
server = [connection rootProxy];
[server setProtocolForProxy:@protocol(MyServerInterface)];
[server doStuff:[mMessage string]];
}
From MyServer
--------------------
@implementation MyServer
- (id) initWithField:(NSText*) displayer
{
if (self = [super init])
mDisplayer = [displayer retain];
return self;
}
-(oneway void) doStuff:(NSString*)message
{
[mDisplayer setString:message];
NSLog(@"Message received: %@", message);
}
_______________________________________________
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.