• 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 NSSocketPort
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using NSSocketPort


  • Subject: Re: Using NSSocketPort
  • From: Charles Bennett <email@hidden>
  • Date: Mon, 22 Apr 2002 16:06:48 -0400

I don't think you ever want to have both send and receive non nil.
I've always assumed that it was a class design decesion to make one
init method othagonal for client and server.

I guess that's a long way of saying, AFAIK, Yes
to your question.


Chuck Bennett

"Michael P. Rogers" wrote:
>
> // server (init the RECEIVE port as it LISTENS for connections)
> NSSocketPort *port = [[NSSocketPort alloc] initWithTCPPort:1234];
> NSConnection *connection = [[NSConnection alloc]
> initWithReceivePort:port sendPort:nil]];
> [connection setRootObject:whateverYourVending];
>
> // client (init the SEND port as it MAKES connections)
> id server;
> NSSocketPort *port = [[NSSocketPort alloc] initWithTCPPort:1234
> host:@"somehost" ]];
> NSConnection *connection = [NSConnection
> connectionWithReceivePort:nil sendPort:port];
> server = [connection rootProxy];
> [server setProtocolForProxy:@protocol(someprotocol)];
>
> >Thanks to the above code my students can now send messages from the
> >client *to* the server. But to go in the opposite direction, do we
> >need to open up a second port, or can we just have the method defined
> >in the proxy return a value and capture that? Which is better?
>
> I've answered part of my own question: with the above, just using
> one port, we can send information back and forth, using arguments to
> send from client to server, and return values to send from server to
> client.
>
> So... why do you even *need* two ports for an NSConnection? Is the
> second port so that the server can *initiate* the connection, i.e.,
> play the role of client?
>
> TIA,
>
> Michael
> --
> Dr. Michael P. Rogers
> Office: 203G Shilling Hall
> Phone: 217-424-6327 (W) 309-828-8655 (H) 309-825-6454 (C)
> E-Mail: email@hidden
>
> Web site: http://math.millikin.edu/
> Astronomy Site: http://twincityamateurastronomers.org
> _______________________________________________
> 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.

--
UPS Management software for OS X
http://www.powerguardian.com
_______________________________________________
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: 
 >Using NSSocketPort (From: Mike Laster <email@hidden>)
 >Re: Using NSSocketPort (From: "Michael P. Rogers" <email@hidden>)
 >Re: Using NSSocketPort (From: "Michael P. Rogers" <email@hidden>)

  • Prev by Date: Create an IB "Informational Text" field Programatically
  • Next by Date: Re: Export data to Excel
  • Previous by thread: Re: Using NSSocketPort
  • Next by thread: Re: Using NSSocketPort
  • Index(es):
    • Date
    • Thread