Up

NSPort class reference

Authors

Richard Frith-Macdonald (richard@brainstorm.co.uk)
Andrew Kachites McCallum (mccallum@gnu.ai.mit.edu)

Version: 37003

Date: 2013-08-22 09:44:54 -0600 (Thu, 22 Aug 2013)

Copyright: (C) 1997,2002 Free Software Foundation, Inc.


Contents -

  1. Software documentation for the NSMessagePort class
  2. Software documentation for the NSPort class
  3. Software documentation for the NSSocketPort class
  4. Software documentation for the NSObject(NSPortDelegateMethods) category

Software documentation for the NSMessagePort class

NSMessagePort : NSPort

Declared in:
Foundation/NSPort.h
Availability: MacOS-X 10.0.0

An NSPort implementation for network object communications which can be used for interthread/interprocess communications on the same host, but not between different hosts.

Instance Variables



Instance Variables for NSMessagePort Class

_internal

@protected void* _internal;
Availability: MacOS-X 10.0.0

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.




Software documentation for the NSPort class

NSPort : NSObject

Declared in:
Foundation/NSPort.h
Conforms to:
NSCoding
NSCopying
Availability: OpenStep

NSPort is an abstract class defining interfaces underlying communications in the distributed objects framework. Each side of a connection will have an NSPort object, responsible for sending and receiving NSPortMessage s, which are then passed to delegates when received. The NSPort must be added to the NSRunLoop as an input source.

This class also implements the functionality of the NSMachPort class on OS X.


Instance Variables

Method summary

port 

+ (NSPort*) port;
Availability: OpenStep

Basic constructor returns object capable of send and receive.
By default, the port returned is an instance of NSMessagePort capable only of host-local communication. However, the NSPortIsMessagePort user default may be set to NO to change the behavior so that the returned value is an instance of the NSSocketPort class.

portWithMachPort: 

+ (NSPort*) portWithMachPort: (NSInteger)machPort;
Availability: OpenStep

NSMachPort compatibility method.

addConnection: toRunLoop: forMode: 

- (void) addConnection: (NSConnection*)aConnection toRunLoop: (NSRunLoop*)aLoop forMode: (NSString*)aMode;
Availability: MacOS-X 10.0.0

Adds to run loop as input source to be notified for input in given mode. This method is for use by subclasses.

delegate 

- (id) delegate;
Availability: OpenStep

Returns the object that received messages will be passed off to.

init 

- (id) init;
Availability: OpenStep

Basic initializer sets up object capable of send and receive. See +port for more details.

initWithMachPort: 

- (id) initWithMachPort: (NSInteger)machPort;
Availability: OpenStep

NSMachPort compatibility method.

invalidate 

- (void) invalidate;
Availability: OpenStep

Mark port as invalid, deregister with listeners and cease further network operations. Subclasses should override and call super.

isValid 

- (BOOL) isValid;
Availability: OpenStep

Returns whether port has been marked invalid.

machPort 

- (NSInteger) machPort;
Availability: OpenStep

NSMachPort compatibility.

removeConnection: fromRunLoop: forMode: 

- (void) removeConnection: (NSConnection*)aConnection fromRunLoop: (NSRunLoop*)aLoop forMode: (NSString*)aMode;
Availability: MacOS-X 10.0.0

Removes from run loop as input source to be notified for input in given mode. This method is for use by subclasses.

reservedSpaceLength 

- (NSUInteger) reservedSpaceLength;
Availability: MacOS-X 10.0.0

Returns amount of space used for header info at beginning of messages. Subclasses should override (this implementation returns 0).

sendBeforeDate: components: from: reserved: 

- (BOOL) sendBeforeDate: (NSDate*)when components: (NSMutableArray*)components from: (NSPort*)receivingPort reserved: (NSUInteger)length;
Availability: MacOS-X 10.0.0

Internal method for sending message, for use by subclasses.

sendBeforeDate: msgid: components: from: reserved: 

- (BOOL) sendBeforeDate: (NSDate*)when msgid: (NSInteger)msgid components: (NSMutableArray*)components from: (NSPort*)receivingPort reserved: (NSUInteger)length;
Availability: MacOS-X 10.0.0

Internal method for sending message, for use by subclasses.

setDelegate: 

- (void) setDelegate: (id)anObject;
Availability: OpenStep

Sets the object that received messages will be passed off to.



Instance Variables for NSPort Class

_delegate

@protected id _delegate;
Availability: OpenStep

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

_is_valid

@protected BOOL _is_valid;
Availability: OpenStep

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.




Software documentation for the NSSocketPort class

NSSocketPort : NSPort

Declared in:
Foundation/NSPort.h
Availability: MacOS-X 10.0.0

An NSPort implementation for network object communications based on BSD sockets. Can be used for interthread/interprocess communications between same or different hosts (though on same host NSMessagePort will be more efficient).

Note that this class is incompatible with the latest OS X version.


Instance Variables

Method summary

existingPortWithNumber: onHost: 

+ (NSSocketPort*) existingPortWithNumber: (uint16_t)number onHost: (NSHost*)aHost;
Availability: MacOS-X 10.0.0

Look up and return an existing NSSocketPort given a host and number, or return nil if one has not been created.

portWithNumber: onHost: forceAddress: listener: 

+ (NSSocketPort*) portWithNumber: (uint16_t)number onHost: (NSHost*)aHost forceAddress: (NSString*)addr listener: (BOOL)shouldListen;
Availability: MacOS-X 10.0.0

This is the preferred initialisation method for NSSocketPort.
number should be a TCP/IP port number or may be zero for a port on the local host.
aHost should be the host for the port or may be nil for the local host.
addr is the IP address that MUST be used for this port - if it is nil then, for the local host, the port uses ALL IP addresses, and for a remote host, the port will use the first address that works.
shouldListen specifies whether to listen on the port initially.

address 

- (NSString*) address;
Availability: MacOS-X 10.0.0

Returns IP address of underlying socket.

getFds: count: 

- (void) getFds: (NSInteger*)fds count: (NSInteger*)count;
Availability: MacOS-X 10.0.0

This is a callback method used by the NSRunLoop class to determine which descriptors to watch for the port.

handlePortMessage: 

- (void) handlePortMessage: (NSPortMessage*)m;
Availability: MacOS-X 10.0.0

Delegates processing of a message.

host 

- (NSHost*) host;
Availability: MacOS-X 10.0.0

Returns host that the underlying socket is connected to.

portNumber 

- (uint16_t) portNumber;
Availability: MacOS-X 10.0.0

Returns port number of underlying socket.



Instance Variables for NSSocketPort Class

address

@protected NSString* address;
Availability: MacOS-X 10.0.0

Description forthcoming.

eventListener

@protected WSAEVENT eventListener;
Availability: MacOS-X 10.0.0

Description forthcoming.

events

@protected NSMapTable* events;
Availability: MacOS-X 10.0.0

Description forthcoming.

handles

@protected NSMapTable* handles;
Availability: MacOS-X 10.0.0

Description forthcoming.

host

@protected NSHost* host;
Availability: MacOS-X 10.0.0

Description forthcoming.

listener

@protected SOCKET listener;
Availability: MacOS-X 10.0.0

Description forthcoming.

myLock

@protected NSRecursiveLock* myLock;
Availability: MacOS-X 10.0.0

Description forthcoming.

portNum

@protected uint16_t portNum;
Availability: MacOS-X 10.0.0

Description forthcoming.




Software documentation for the NSObject(NSPortDelegateMethods) category

NSObject(NSPortDelegateMethods)

Declared in:
Foundation/NSPort.h
Availability: OpenStep

Description forthcoming.
Method summary

handlePortMessage: 

- (void) handlePortMessage: (NSPortMessage*)aMessage;
Availability: OpenStep

An empty method provided for subclasses to override.
Subclasses of NSPort send this message to their delegate on receipt of a port message.


Up