Inherits From:
NSObject
Conforms To:
NSCoding
NSCopying
NSObject (NSObject)
Declared In:
Foundation/NSPort.h
handleMachMessage:
or handlePortMessage:
message. The delegate should implement only one of these methods to process the incoming message in whatever form desired. handleMachMessage:
provides a message as a raw Mach message beginning with a msg_header_t
structure. handlePortMessage:
provides a message as an NSPortMessage object, which is an object-oriented wrapper for a Mach message.
NSPort is intended to receive incoming messages need to be added to an NSRunLoop. See the NSRunLoop class specification for more information.
port
Creates and returns a new NSPort object capable of both sending and receiving messages.
portWithMachPort:
(int)machPort
Returns an NSPort object that uses the Mach port machPort (which should be of type port_t
cast to int
). Creates the NSPort object if necessary. Depending on the access rights for machPort, the new NSPort may only be able to send messages.
addConnection:
(NSConnection *)conn toRunLoop:
(NSRunLoop *)runLoop forMode:
(NSString *)mode
<< Description forthcoming. >>
delegate
Returns the NSPort's delegate.
See also:
- setDelegate:
init
Initializes a newly allocated NSPort object to be capable of both sending and receiving messages. Returns self
.
initWithMachPort:
(int)machPort
Initializes a newly allocated NSPort object to use the Mach port machPort (which should be of type port_t
cast to int
). Depending on the access rights for machPort, the new NSPort may only be able to send messages. If an NSPort with machPort already exists, deallocates the receiver, then retains and returns the existing NSPort.
This method is the designated initializer for the NSPort class. Returns self
.
invalidate
Marks the NSPort as invalid and posts an NSPortDidBecomeInvalidNotification to the default notification center.
See also:
- isValid
isValid
Returns NO if the NSPort is known to be invalid, YES otherwise (an NSPort only notes that it has become invalid when it tries to send or receive a message). An NSPort becomes invalid when its underlying communication resource, which is operating-system dependent, is closed or damaged.
See also:
- invalidate
machPort
Returns as an int
the Mach port used by the NSPort. Cast this value to a port_t
when using it with Mach system calls.
removeConnection:
(NSConnection *)conn fromRunLoop:
(NSRunLoop *)runLoop forMode:
(NSString *)mode
<< Description forthcoming. >>
reservedSpaceLength
<< Description forthcoming. >>
sendBeforeDate:
(NSDate *)limitDate components:
(NSMutableArray *)components from:
(NSPort *)receivePort reserved:
(unsigned)headerSpaceReserved
<< Description forthcoming. >>
setDelegate:
(id)anObject
Sets the NSPort's delegate to anObject. Doesn't retain anObject.
See also:
- delegate
Methods Implemented By the Delegate
handleMachMessage:
(void *)machMessage
Processes machMessage, an incoming Mach message cast as a pointer to void
. The delegate should interpret this data as a pointer to a Mach message beginning with a msg_header_t
structure and should handle the message appropriately.
The delegate should implement only one of handleMachMessage:
and handlePortMessage:
.
handlePortMessage:
(NSPortMessage *)portMessage
Processes portMessage, an incoming message on the NSPort. See the NSPortMessage class specification for more information.
The delegate should implement only one of handleMachMessage:
and handlePortMessage:
.
invalidate
method, which is invoked when the NSPort is deallocated or when it notices that its communication channel has been damaged. This notification contains a notification object but no userInfo dictionary. The notification object is the NSPort object that has become invalid.The NSPort object posting this notification is no longer useful, so all receivers should unregister themselves for any notifications involving the NSPort.