• 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: "Michael P. Rogers" <email@hidden>
  • Date: Sun, 21 Apr 2002 19:13:27 -0500

At 20:26 -0400 20/4/02, Mike Laster wrote:
>Does anyone have any sample code on how to use NSSocketPort?

Here's an example from cocoadevcentral, written by H. Lally Singh:

http://www.cocoadevcentral.com/tutorials/showpage.php?show=00000038.php


// 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)];

It doesn't compile -- I believe that initWithTCPPort:host: needs to
be initRemoteWithTCPPort:host: -- but other than that it's fine.

Related to this, I have a question which I hope somebody can answer.

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?

Thanks,

Michael
--
---------------------------------
Dr. Michael Rogers
e-mail: email@hidden
Phone: 217-424-6327

For information about Computer Science at Millikin University, visit
http://math.millikin.edu
For information about astronomy, check out
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.

  • Follow-Ups:
    • Re: Using NSSocketPort
      • From: "Michael P. Rogers" <email@hidden>
    • Re: Using NSSocketPort
      • From: Mike Laster <email@hidden>
References: 
 >Using NSSocketPort (From: Mike Laster <email@hidden>)

  • Prev by Date: appending attributed strings
  • Next by Date: Re: Compile times
  • Previous by thread: Using NSSocketPort
  • Next by thread: Re: Using NSSocketPort
  • Index(es):
    • Date
    • Thread