Re: DOs and DOn'ts
Re: DOs and DOn'ts
- Subject: Re: DOs and DOn'ts
- From: Isaac Sherman <email@hidden>
- Date: Tue, 26 Feb 2002 23:03:28 -0500
on 2/26/02 4:57 PM, you, Ondra Cada, at the address, email@hidden, wrote:
>
Isaac,
>
>
>>>>>> Isaac Sherman (IS) wrote at Mon, 25 Feb 2002 18:11:23 -0500:
>
IS> id * theProxy = [[NSConnection
>
IS> rootProxyForConnectionWithRegisteredName:@"myServer"
>
IS> host:nil] retain];//I've used both
>
IS> nil and @"*" to no avail
>
IS> NSLog(@"the proxy is of class %@\n", [theProxy class]);
>
IS> NSLog(@"The name of the vended object is %@\n", [theProxy getName]);/*the
>
IS> vended object has a name, and responds to this method*/
>
IS>
>
IS>
>
IS> Both NSLogs report (null), and I'm completely lost as to why.
>
>
That makes two of us. This looks reasonably. Are you sure you (a) use
>
host:nil, and (b) have both the server and client running on the same
>
machine?
>
>
Anyway, this one does work:
>
>
114 /tmp> cat q.m
>
// simplest server/client via DO
>
#import <Foundation/Foundation.h>
>
#define NAME @"Just test"
>
void main() {
>
NSAutoreleasePool *pool=[NSAutoreleasePool new];
>
id server=[NSConnection rootProxyForConnectionWithRegisteredName:NAME
>
host:nil];
>
>
if (server) {
>
NSLog(@"I'm a client just now. I'm about to send a message...");
>
NSLog(@"with the result %@",[server description]);
>
NSLog(@"That's all, bye!");
>
} else {
>
NSConnection *conn=[NSConnection defaultConnection];
>
NSLog(@"I'm here to serve!");
>
[conn setRootObject:[NSScanner new]]; // use any class you want to here
>
if (![conn registerName:NAME]) NSLog(@"Oops?!?");
>
else {
>
[conn runInNewThread];
>
NSLog(@"enter 'q' and press Enter to quit");
>
while (getchar()!='q');
>
}
>
}
>
[pool release];
>
}
>
115 /tmp> cc -Wall -framework Foundation q.m -o q
>
q.m:4: warning: return type of `main' is not `int'
>
116 /tmp> ./q
>
2002-02-26 22:56:58.187 q[1956] I'm here to serve!
>
2002-02-26 22:56:58.193 q[1956] enter 'q' and press Enter to quit
>
^Z
>
zsh: suspended ./q
>
117 /tmp> bg %%
>
[2] - continued ./q
>
118 /tmp> ./q
>
2002-02-26 22:57:10.175 q[1957] I'm a client just now. I'm about to send a
>
message...
>
2002-02-26 22:57:10.181 q[1957] with the result <NSConcreteScanner: 0x949c0>
>
2002-02-26 22:57:10.183 q[1957] That's all, bye!
>
119 /tmp>
>
---
>
Ondra Cada
>
OCSoftware: email@hidden http://www.ocs.cz
>
2K Development: email@hidden http://www.2kdevelopment.cz
>
private email@hidden http://www.ocs.cz/oc
>
_______________________________________________
>
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.
Very odd. In Terminal (as well as Project Builder) server reports null, and
never enters the "I'm a client..." section. Which, at first glance to me,
looks like a problem with my framework specifically. Any ideas? Should I
re-install OS X, or maybe just the frameworks (if that's doable)?
--
Isaac Sherman
MotaSoft Software
_______________________________________________
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.