Class

NSPortMessage

A low-level, operating system-independent type for inter-application (and inter-thread) messages.

Overview

Port messages are used primarily by the distributed objects system. You should implement inter-application communication using distributed objects whenever possible and use NSPortMessage only when necessary.

An NSPortMessage object has three major parts: the send and receive ports, which are NSPort objects that link the sender of the message to the receiver, and the components, which form the body of the message. The components are held as an NSArray object containing NSData and NSPort objects. The sendBeforeDate: message sends the components out through the send port; any replies to the message arrive on the receive port. See the NSPort class specification for information on handling incoming messages.

An NSPortMessage instance can be initialized with a pair of NSPort objects and an array of components. A port message's body can contain only NSPort objects or NSData objects. In the distributed objects system the byte/character arrays are usually encoded NSInvocation objects that are being forwarded from a proxy to the corresponding real object.

An NSPortMessage object also maintains a message identifier, which can be used to indicate the class of a message, such as an Objective-C method invocation, a connection request, an error, and so on. Use the msgid and msgid methods to access the identifier.

Topics

Creating Instances

initWithSendPort:receivePort:components:

Initializes a newly allocated NSPortMessage object to send given data on a given port and to receiver replies on another given port.

Sending the Message

sendBeforeDate:

Attempts to send the message before aDate, returning YES if successful or NO if the operation times out.

Getting the Components

components

Returns the data components of the receiver.

Getting the Ports

receivePort

For an outgoing message, returns the port on which replies to the receiver will arrive. For an incoming message, returns the port the receiver did arrive on.

sendPort

For an outgoing message, returns the port the receiver will send itself through. For an incoming message, returns the port replies to the receiver should be sent through.

Accessing the Message ID

msgid

Returns the identifier for the receiver.

Relationships

Inherits From

See Also

Legacy

NSMachPortDelegate

An interface for handling incoming Mach messages.

NSConnectionDelegate

An interface for interacting with low-level, interprocess connections.

Deprecated
NSConnection

An object that manages the communication between objects in different threads or between a thread and a process running on a local or remote system.

Deprecated
NSDistantObject

A proxy for objects in other applications or threads.

Deprecated
NSDistantObjectRequest

An object used by the distributed objects system to help handle invocations between different processes.

Deprecated
NSMachBootstrapServer

A port name server that takes and returns Mach port objects.

Deprecated
NSMachPort

A port that can be used as an endpoint for distributed object connections (or raw messaging).

NSMessagePort

A port that can be used as an endpoint for distributed object connections (or raw messaging).

NSMessagePortNameServer

A server takes and returns message ports.

Deprecated
NSPortCoder

A coder used to transmit object proxies (and sometimes objects themselves) between connections.

Deprecated
NSPortDelegate

An interface for handling incoming messages.

NSPortNameServer

An object-oriented interface to the port registration service used by the distributed objects system.

Deprecated
NSProtocolChecker

An object that restricts the messages that can be sent to another object (referred to as the checker’s delegate).

NSSocketPortNameServer

A port name server that takes and returns socket ports.

Deprecated