Up

NSPort class reference

Authors

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

Version: 1.30

Date: 2005/02/22 11:22:44

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 NSPort(GNUstep) category

Software documentation for the NSMessagePort class

NSMessagePort : NSPort

Declared in:
Foundation/NSPort.h
Conforms to:
GCFinalization
Standards:

An NSPort implementation for network object communications based on Unix domain sockets. Can be used for interthread/interprocess communications on the same host, but not between different hosts.


Instance Variables

Method summary

_portWithName: listener: 

+ (NSMessagePort*) _portWithName: (const unsigned char*)socketName listener: (BOOL)shouldListen;
This is a designated initialiser for the class.

This is the preferred initialisation method for NSMessagePort. socketName is the name of the socket in the port directory
Warning the underscore at the start of the name of this method indicates that it is private, for internal use only, and you should not use the method in your code.


_listener 

- (int) _listener;

Warning the underscore at the start of the name of this method indicates that it is private, for internal use only, and you should not use the method in your code.


_name 

- (const unsigned char*) _name;

Warning the underscore at the start of the name of this method indicates that it is private, for internal use only, and you should not use the method in your code.


addHandle: forSend: 

- (void) addHandle: (GSMessageHandle*)handle forSend: (BOOL)send;

Setup method: add new send or receive connection handle.


handlePortMessage: 

- (void) handlePortMessage: (NSPortMessage*)m;

Delegates processing of a message.


removeHandle: 

- (void) removeHandle: (GSMessageHandle*)handle;

This is called when a socket connection is broken. We remove the connection handle from this port and, if this was the last handle to a remote port, we invalidate the port.




Instance Variables for NSMessagePort Class

handles

@protected NSMapTable* handles;

Description forthcoming.


listener

@protected int listener;

Description forthcoming.


myLock

@protected NSRecursiveLock* myLock;

Description forthcoming.


name

@protected NSData* name;

Description forthcoming.





Software documentation for the NSPort class

NSPort : NSObject

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

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;

Basic constructor returns object capable of send and receive.


portWithMachPort: 

+ (NSPort*) portWithMachPort: (int)machPort;

NSMachPort compatibility method.


addConnection: toRunLoop: forMode: 

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

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;

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


init 

- (id) init;

Basic initializer sets up object capable of send and receive.


initWithMachPort: 

- (id) initWithMachPort: (int)machPort;

NSMachPort compatibility method.


invalidate 

- (void) invalidate;

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


isValid 

- (BOOL) isValid;

Returns whether port has been marked invalid.


machPort 

- (int) machPort;

NSMachPort compatibility.


removeConnection: fromRunLoop: forMode: 

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

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


reservedSpaceLength 

- (unsigned) reservedSpaceLength;

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: (unsigned)length;

Internal method for sending message, for use by subclasses.


sendBeforeDate: msgid: components: from: reserved: 

- (BOOL) sendBeforeDate: (NSDate*)when msgid: (int)msgid components: (NSMutableArray*)components from: (NSPort*)receivingPort reserved: (unsigned)length;

Internal method for sending message, for use by subclasses.


setDelegate: 

- (void) setDelegate: (id)anObject;

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




Instance Variables for NSPort Class

_delegate

@protected id _delegate;

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;

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
Conforms to:
GCFinalization
Standards:

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: (gsu16)number onHost: (NSHost*)aHost;

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: (gsu16)number onHost: (NSHost*)aHost forceAddress: (NSString*)addr listener: (BOOL)shouldListen;

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.


addHandle: forSend: 

- (void) addHandle: (GSTcpHandle*)handle forSend: (BOOL)send;

Setup method: add new send or receive connection handle.


address 

- (NSString*) address;

Returns IP address of underlying socket.


getFds: count: 

- (void) getFds: (int*)fds count: (int*)count;

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


handleForPort: beforeDate: 

- (GSTcpHandle*) handleForPort: (NSSocketPort*)recvPort beforeDate: (NSDate*)when;

Description forthcoming.


handlePortMessage: 

- (void) handlePortMessage: (NSPortMessage*)m;

Delegates processing of a message.


host 

- (NSHost*) host;

Returns host that the underlying socket is connected to.


portNumber 

- (gsu16) portNumber;

Returns port number of underlying socket.


removeHandle: 

- (void) removeHandle: (GSTcpHandle*)handle;

This is called when a TCP/IP socket connection is broken. We remove the connection handle from this port and, if this was the last handle to a remote port, we invalidate the port.




Instance Variables for NSSocketPort Class

address

@protected NSString* address;

Description forthcoming.


handles

@protected NSMapTable* handles;

Description forthcoming.


host

@protected NSHost* host;

Description forthcoming.


listener

@protected SOCKET listener;

Description forthcoming.


myLock

@protected NSRecursiveLock* myLock;

Description forthcoming.


portNum

@protected gsu16 portNum;

Description forthcoming.





Software documentation for the NSPort(GNUstep) category

NSPort(GNUstep)

Declared in:
Foundation/NSPort.h
Standards:

Stubs for backward compatibility. Do not use.

Method summary

outPacketClass 

+ (Class) outPacketClass;

Description forthcoming.


close 

- (void) close;

Description forthcoming.


outPacketClass 

- (Class) outPacketClass;

Description forthcoming.



Up