O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

NSSocketPort — Mac OS X 10.0

Synopsis

This subclass of NSPort provides an interface to objects that can serve as endpoints for distributed objects connections over a network. NSSocketPort is implemented using the BSD Sockets API, which makes it useful for raw network communications in addition to serving as a component of the distributed objects system. A socket file descriptor that is suitable for use with the BSD Sockets API can be obtained by sending a socket message to an instance of this class.

While local communication is supported in socket ports, it is generally more efficient in terms of resource usage to use NSMachPort or NSMessagePort for local distributed objects connections.

image with no caption

@interface NSSocketPort : NSPort
                                  // Initializers
   - (id)init;
   - (id)initRemoteWithProtocolFamily:(int)family 
                                 socketType:(int)type 
                                 protocol:(int)protocol 
                                 address:(NSData *)address;
   - (id)initRemoteWithTCPPort:(unsigned short)port 
                                 host:(NSString *)hostName;
   - (id)initWithProtocolFamily:(int)family  
                                 socketType:(int)type 
                                 protocol:(int)protocol 
                                 address:(NSData *)address;
   - (id)initWithProtocolFamily:(int)family  
                                 socketType:(int)type 
                                 protocol:(int)protocol 
                                 socket:(NSSocketNativeHandle)sock;
   - (id)initWithTCPPort:(unsigned short)port;
                                  // Instance Methods
   - (NSData *)address;
   - (int)protocol;
   - (int)protocolFamily;
   - (NSSocketNativeHandle)socket;
   - (int)socketType;

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required