Class: NSMachPort

Inherits:
NSPort show all

Overview

NSMachPort is a subclass of NSPort that can be used as an endpoint for distributed object connections (or raw messaging). NSMachPort is an object wrapper for a Mach port, the fundamental communication port in OS X. NSMachPort allows for local (on the same machine) communication only. A companion class, NSSocketPort, allows for both local and remote distributed object communication, but may be more expensive than NSMachPort for the local case.

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSPort

#invalidate, #isValid, port, #reservedSpaceLength, #sendBeforeDate:components:from:reserved:, #sendBeforeDate:msgid:components:from:reserved:

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Class Method Details

+ (NSPort) portWithMachPort(machPort)

Creates and returns a port object configured with the given Mach port. Creates the port object if necessary. Depending on the access rights associated with machPort, the new port object may be usable only for sending messages.

Parameters:

  • machPort (Integer)

    The Mach port for the new port. This parameter should originally be of type mach_port_t.

Returns:

  • (NSPort)

    An NSMachPort object that uses machPort to send or receive messages.

+ (NSPort) portWithMachPort(machPort, options:options)

Creates and returns a port object configured with the specified options and the given Mach port. Creates the port object if necessary. Depending on the access rights associated with machPort, the new port object may be usable only for sending messages.

Parameters:

  • machPort (Integer)

    The Mach port for the new port. This parameter should originally be of type mach_port_t.

  • options (Integer)

    Specifies options for what to do with the underlying port rights when the NSMachPort object is invalidated or destroyed. For a list of constants, see “Mach Port Rights.”

Returns:

  • (NSPort)

    An NSMachPort object that uses machPort to send or receive messages.

Instance Method Details

- (Object) delegate

Returns the receiver’s delegate.

Returns:

  • (Object)

    The receiver’s delegate.

- (Object) initWithMachPort(machPort)

Initializes a newly allocated NSMachPort object with a given Mach port. Depending on the access rights for machPort, the new port may be able to only send messages. If a port with machPort already exists, this method deallocates the receiver, then retains and returns the existing port.This method is the designated initializer for the NSMachPort class.

Parameters:

  • machPort (Integer)

    The Mach port for the new port. This parameter should originally be of type mach_port_t.

Returns:

  • (Object)

    Returns an initialized NSMachPort object that uses machPort to send or receive messages. The returned object might be different than the original receiver

- (Object) initWithMachPort(machPort, options:options)

Initializes a newly allocated NSMachPort object with a given Mach port and the specified options. Depending on the access rights for machPort, the new port may be able to only send messages. If a port with machPort already exists, this method deallocates the receiver, then retains and returns the existing port.

Parameters:

  • machPort (Integer)

    The Mach port for the new port. This parameter should originally be of type mach_port_t.

  • options (Integer)

    Specifies options for what to do with the underlying port rights when the NSMachPort object is invalidated or destroyed. For a list of constants, see “Mach Port Rights.”

Returns:

  • (Object)

    Returns an initialized NSMachPort object that uses machPort to send or receive messages. The returned object might be different than the original receiver

- (Integer) machPort

Returns as an int the Mach port used by the receiver.

Returns:

  • (Integer)

    The Mach port used by the receiver. Cast this value to a mach_port_t when using it with Mach system calls.

- (Object) removeFromRunLoop(runLoop, forMode:mode)

Removes the receiver from the run loop mode mode of runLoop. When the receiver is removed, the run loop stops monitoring the Mach port for incoming messages.

Parameters:

  • runLoop (NSRunLoop)

    The run loop from which to remove the receiver.

  • mode (String)

    The run loop mode from which to remove the receiver.

Returns:

- (Object) scheduleInRunLoop(runLoop, forMode:mode)

Schedules the receiver into the run loop mode mode of runLoop. When the receiver is scheduled, the run loop monitors the mach port for incoming messages and, when a message arrives, invokes the delegate method handleMachMessage:.

Parameters:

  • runLoop (NSRunLoop)

    The run loop to which to add the receiver.

  • mode (String)

    The run loop mode in which to add the receiver.

Returns:

- (Object) setDelegate(anObject)

Sets the receiver’s delegate to a given object.

Parameters:

  • anObject (Object)

    The delegate for the receiver.

Returns: