discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with NSSocketPort and DO on WINDOWS


From: Jamie Ramone
Subject: Re: Problems with NSSocketPort and DO on WINDOWS
Date: Fri, 19 Jun 2009 13:05:04 -0300

On Fri, Jun 19, 2009 at 12:03 PM, Samantha Rahn<samantha.rahn@gmail.com> wrote:
> All,
> I have been having a variety of trouble with DO on Windows when
> communicating across hosts.  In order to diagnose the problem, I have
> simplified my code to avoid the name server and simply use DO with
> sockets (NSSocketPort).  After setting up 2 processes, my client code
> fails when trying to acquire the rootProxy from the connection.  An
> error is evidenced on the server side.
>
> The server error occurs in the NSSocketPort class when the message is
> received.  The error message is:
>         "No handle for event rport on descriptor 0"
>
> Client code:
>
> - (BOOL)connectToHost:(NSString *)aHost
> {
>    NSHost *host = aHost ? [NSHost hostWithName:aHost] : nil;
>    NSSocketPort *receivePort = [NSSocketPort portWithNumber:3999
> onHost:host forceAddress:nil listener:YES];
>    NSSocketPort *sendPort     = [NSSocketPort portWithNumber:3998
> onHost:host forceAddress:nil listener:NO];
>    NSConnection *connection = [NSConnection
> connectionWithReceivePort:receivePort sendPort:sendPort];
>
>    BOOL status = connection!=nil;
>
>    if(status)
>    {
>        ASSIGN(rootProxy, [connection rootProxy]);  // Error occurs on
> server prompted from this client call.
>        ASSIGN(hostName, aHost);
>    }
>
>    return rootProxy!=nil;
> }
>
> Server code:
> - (void)start
> {
>        NSSocketPort *receivePort = [NSSocketPort portWithNumber:3998
> onHost:nil forceAddress:nil listener:YES];
>        NSSocketPort *sendPort    = [NSSocketPort portWithNumber:3999
> onHost:nil forceAddress:nil listener:NO];
>        ASSIGN(connection, [NSConnection
> connectionWithReceivePort:receivePort sendPort:sendPort]);
>
>        [connection setRootObject:self];
>    }
> }
>
> Thanks,
> Sam
>
>
> _______________________________________________
> Discuss-gnustep mailing list
> Discuss-gnustep@gnu.org
> http://lists.gnu.org/mailman/listinfo/discuss-gnustep
>

Hi Sam. First off, you should never, ever, ever, in your wildest
dreams, think of imagining of trying to fool around with ports unless
you have a good reazon to do so.

The usal way to do things is to have the server vend the object to
share using -setRootObject: after getting the deffault connection for
that thread. Then the client uses -rootProxy to get the object.

I've never fucked around with ports (since you shouldn't have to: the
Foundation framework hides those details from you), but what you did
is ALMOST correct. What you're lacking is to add the read port to the
server's thread's run loop (which you can get using NSRunLoop's
+currentRunlLoop factory method). To do so you use the
-addPortForMode:, but I have no idea about using it.

The lack of the port in the run loop is most likely the cause of your
grief. Look at 
http://developer.apple.com/documentation/Cocoa/Conceptual/DistrObjects/DistrObjects.html
for info on DO in geneeral and
http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/Introduction/Introduction.html
for run loops (it's one of the last sections of that document).

Hope that helped.
-- 
Besos, abrazos, confeti y aplausos.
Jamie Ramone
"El Vikingo"




reply via email to

[Prev in Thread] Current Thread [Next in Thread]