• 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: Mike Laster <email@hidden>
  • Date: Sun, 21 Apr 2002 21:30:59 -0400

On 4/21/02 8:13 PM, "Michael P. Rogers" <email@hidden> wrote:

> 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?

This isn't really what I'm wanting to do. I'm trying to make a server for
an existing network protocol, so therefore I can't use NSConnection. I just
trying to use NSSocketPort in order to accept connections within the run
loop.
_______________________________________________
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: email@hidden
    • Re: Using NSSocketPort
      • From: "Michael P. Rogers" <email@hidden>
References: 
 >Re: Using NSSocketPort (From: "Michael P. Rogers" <email@hidden>)

  • Prev by Date: Re: Compile times
  • Next by Date: Re: table view cell vertically centered?
  • Previous by thread: Re: Using NSSocketPort
  • Next by thread: Re: Using NSSocketPort
  • Index(es):
    • Date
    • Thread