Class: NSNetService
Overview
The NSNetService class represents a network service that your application publishes or uses as a client. This class and the NSNetServiceBrowser class use multicast DNS to convey information about network services to and from your application. The API of NSNetService provides a convenient way to publish the services offered by your application and to resolve the socket address for a service.
Class Method Summary (collapse)
-
+ dataFromTXTRecordDictionary:
Returns an NSData object representing a TXT record formed from a given dictionary.
-
+ dictionaryFromTXTRecordData:
Returns a dictionary representing a TXT record given as an NSData object.
Instance Method Summary (collapse)
-
- addresses
Returns an array containing NSData objects, each of which contains a socket address for the service.
-
- delegate
Returns the delegate for the receiver.
-
- domain
Returns the domain name of the service.
-
- getInputStream:outputStream:
Retrieves by reference the input and output streams for the receiver and returns a Boolean value that indicates whether they were retrieved successfully.
-
- hostName
Returns the host name of the computer providing the service.
-
- initWithDomain:type:name:
Returns the receiver, initialized as a network service of a given type and sets the initial host information.
-
- initWithDomain:type:name:port:
Initializes the receiver as a network service of type type at the socket location specified by domain, name, and port.
-
- name
Returns the name of the service.
-
- port
Provides the port of the receiver.
-
- publish
Attempts to advertise the receiver’s on the network.
-
- publishWithOptions:
Attempts to advertise the receiver on the network, with the given options.
-
- removeFromRunLoop:forMode:
Removes the service from the given run loop for a given mode.
-
- resolveWithTimeout:
Starts a resolve process of a finite duration for the receiver.
-
- scheduleInRunLoop:forMode:
Adds the service to the specified run loop.
-
- setDelegate:
Sets the delegate for the receiver.
-
- setTXTRecordData:
Sets the TXT record for the receiver, and returns a Boolean value that indicates whether the operation was successful.
-
- startMonitoring
Starts the monitoring of TXT-record updates for the receiver.
-
- stop
Halts a currently running attempt to publish or resolve a service.
-
- stopMonitoring
Stops the monitoring of TXT-record updates for the receiver.
-
- TXTRecordData
Returns the TXT record for the receiver.
-
- type
Returns the type of the service.
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
Instance Method Details
- (Array) addresses
Returns an array containing NSData objects, each of which contains a socket address for the service. It is possible for a single service to resolve to more than one address or not resolve to any addresses. A service might resolve to multiple addresses if the computer publishing the service is currently multihoming.
- (Object) delegate
Returns the delegate for the receiver.
- (String) domain
Returns the domain name of the service.
- (Boolean) getInputStream(inputStream, outputStream:outputStream)
Retrieves by reference the input and output streams for the receiver and returns a Boolean value that indicates whether they were retrieved successfully. After this method is called, no delegate callbacks are called by the receiver.
- (String) hostName
Returns the host name of the computer providing the service.
- (Object) initWithDomain(domain, type:type, name:name)
Returns the receiver, initialized as a network service of a given type and sets the initial host information. This method is the appropriate initializer to use to resolve a service—to publish a service, use initWithDomain:type:name:port:.If you know the values for domain, type, and name of the service you wish to connect to, you can create an NSNetService object using this initializer and call resolveWithTimeout: on the result. You cannot use this initializer to publish a service. This initializer passes an invalid port number to the designated initializer, which prevents the service from being registered. Calling publish on an NSNetService object initialized with this method generates a call to your delegate’s netService:didNotPublish: method with an NSNetServicesBadArgumentError error.
- (Object) initWithDomain(domain, type:type, name:name, port:port)
Initializes the receiver as a network service of type type at the socket location specified by domain, name, and port. You use this method to create a service that you wish to publish on the network. Although you can also use this method to create a service you wish to resolve on the network, it is generally more appropriate to use the initWithDomain:type:name: method instead.When publishing a service, you must provide valid arguments in order to advertise your service correctly. If the host computer has access to multiple registration domains, you must create separate NSNetService objects for each domain. If you attempt to publish in a domain for which you do not have registration authority, your request may be denied.It is acceptable to use an empty string for the domain argument when publishing or browsing a service, but do not rely on this for resolution.This method is the designated initializer.
- (String) name
Returns the name of the service.
- (Integer) port
Provides the port of the receiver.
- (Object) publish
Attempts to advertise the receiver’s on the network. This method returns immediately, with success or failure indicated by the callbacks to the delegate.
- (Object) publishWithOptions(serviceOptions)
Attempts to advertise the receiver on the network, with the given options. This method returns immediately, with success or failure indicated by the callbacks to the delegate.
- (Object) removeFromRunLoop(aRunLoop, forMode:mode)
Removes the service from the given run loop for a given mode. You can use this method in conjunction with scheduleInRunLoop:forMode: to transfer the service to a different run loop. Although it is possible to remove an NSNetService object completely from any run loop and then attempt actions on it, it is an error to do so.
- (Object) resolveWithTimeout(timeout)
Starts a resolve process of a finite duration for the receiver. If the resolve succeeds before the timeout period lapses, the receiver sends netServiceDidResolveAddress: to the delegate. Otherwise, the receiver sends netService:didNotResolve: to the delegate.
- (Object) scheduleInRunLoop(aRunLoop, forMode:mode)
Adds the service to the specified run loop. You can use this method in conjunction with removeFromRunLoop:forMode: to transfer a service to a different run loop. You should not attempt to run a service on multiple run loops.
- (Object) setDelegate(delegate)
Sets the delegate for the receiver. The delegate is not retained.
- (Boolean) setTXTRecordData(recordData)
Sets the TXT record for the receiver, and returns a Boolean value that indicates whether the operation was successful.
- (Object) startMonitoring
Starts the monitoring of TXT-record updates for the receiver. The delegate must implement netService:didUpdateTXTRecordData:, which is called when the TXT record for the receiver is updated.
- (Object) stop
Halts a currently running attempt to publish or resolve a service. This method results in the sending of a netServiceDidStop: message to the delegate.
- (Object) stopMonitoring
Stops the monitoring of TXT-record updates for the receiver.
- (NSData) TXTRecordData
Returns the TXT record for the receiver.
- (String) type
Returns the type of the service.