Inherits from: NSObject
Conforms to: NSObject
(NSObject)
Declared in: Foundation/NSPortMessage.h
An NSPortMessage defines a low level, operating-system independent type for interapplication (and interthread) messages. NSPortMessages are used primarily by the distributed objects system. You should implement interapplication communication using distributed objects whenever possible, and use NSPortMessages only when necessary.
An NSPortMessage has three major parts: the send and receive ports, which are NSPorts 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 of NSData and NSPort objects. NSPortMessage's 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 can be initialized with a Mach message or
with a pair of NSPorts and an NSArray of components. In either case,
an NSPortMessage's body can contain only the types in the table
below. The types listed under initWithMachMessage: are
converted to the corresponding object type listed under initWithSendPort:receivePort:components:.
In the distributed objects system the byte/character arrays are
usually encoded NSInvocations that are being forwarded from a proxy
to the corresponding real object.
initWithMachMessage: | initWithSendPort:receivePort:components: |
port_t | NSPort object |
MSG_TYPE_BYTE | NSData object |
MSG_TYPE_CHAR | |
MSG_TYPE_INTEGER_32 |
An NSPortMessage 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 setMsgid: and msgid methods to access the identifier.
- Creating instances
- - initWithMachMessage:
- - initWithSendPort:receivePort:components:
- Sending the message
- - sendBeforeDate:
- Getting the components
- - components
- Getting the ports
- - receivePort
- - sendPort
- Accessing the message ID
- - setMsgid:
- - msgid
- (NSArray *)components
- (id)initWithMachMessage:(void
*)buffer
See the class description for restrictions on the allowable types in the body of the Mach message.
- (id)initWithSendPort:(NSPort
*)sendPort
receivePort:(NSPort *)receivePort
components:(NSArray *)components
components should contain only NSData and NSPort objects, and the contents of the NSData objects should be in network byte order.
See Also: - setMsgid:
- (unsigned int)msgid
See Also: - setMsgid:
- (NSPort *)receivePort
See Also: - sendPort
- (BOOL)sendBeforeDate:(NSDate
*)aDate
- (NSPort *)sendPort
See Also: - receivePort
- (void)setMsgid:(unsigned
int)msgid
See Also: - msgid