Xojo Conferences
XDCApr2018DenverUSA
MBSSep2018MunichEurope

MBS Xojo Network Kit

NSNetServiceMB class:

Class NSNetServiceMB
ComputedProperty Description As text
Sub Set() End
Sub Get() End
End ComputedProperty
ComputedProperty TXTRecordData As MemoryBlock
Sub Set() // Sets the TXT record of the NSNetService instance that has been or will be published. // Pass nil to remove the TXT record from the instance. End
Sub Get() // Returns the raw TXT record of the NSNetService instance. // If the instance has not been resolved, or the DidUpdateTXTRecordData event has not been called, this will return nil. // It is permitted to have a zero-length TXT record. End
End ComputedProperty
ComputedProperty addressIPv4 As text
Sub Set() End
Sub Get() // get first IPv4 address End
End ComputedProperty
ComputedProperty addressIPv6 As text
Sub Set() End
Sub Get() // get first IPv6 address End
End ComputedProperty
ComputedProperty className As text
Sub Set() End
Sub Get() End
End ComputedProperty
ComputedProperty domain As text
Sub Set() End
Sub Get() // Returns the domain of the discovered or published service. End
End ComputedProperty
ComputedProperty hostName As text
Sub Set() End
Sub Get() // Returns the DNS host name of the computer hosting the discovered or published service. // If a successful resolve has not yet occurred, this method will return "". End
End ComputedProperty
ComputedProperty includesPeerToPeer As Boolean
Sub Set() // Initially set to false. // Set to true to also publish, resolve, or monitor this service over peer to peer Bluetooth and Wi-Fi (if available). // Must be set before operation starts. End
Sub Get() // Initially set to false. // Set to true to also publish, resolve, or monitor this service over peer to peer Bluetooth and Wi-Fi (if available). // Must be set before operation starts. End
End ComputedProperty
ComputedProperty name As text
Sub Set() End
Sub Get() // Returns the name of the discovered or published service. End
End ComputedProperty
ComputedProperty port As Integer
Sub Set() End
Sub Get() // The port of a resolved service. This returns -1 if the service has not been resolved. End
End ComputedProperty
ComputedProperty type As text
Sub Set() End
Sub Get() // Returns the type of the discovered or published service. End
End ComputedProperty
Const FoundationLib = Foundation
Const NSNetServiceDelegateMBSKit = NSNetServiceDelegateMBSKit
Const NSNetServiceListenForConnections = 2
Const NSNetServiceNoAutoRename = 1
Const NSNetServicesActivityInProgress = -72003
Const NSNetServicesBadArgumentError = -72004
Const NSNetServicesCancelledError = -72005
Const NSNetServicesCollisionError = -72001
Const NSNetServicesInvalidError = -72006
Const NSNetServicesNotFoundError = -72002
Const NSNetServicesTimeoutError = -72007
Const NSNetServicesUnknownError = -72000
Event DidResolveAddress() End
Event didNotPublish(ErrorDomain as Integer, ErrorCode as Integer) End
Event didNotResolve(ErrorDomain as Integer, ErrorCode as Integer) End
Event didPublish() End
Event didStop() End
Event didUpdateTXTRecordData(data as MemoryBlock) End
Event willPublish() End
Event willResolve() End
Sub CheckEvents() // for console only // runs runloop for one round to check for events End
Sub Constructor(Handle as Integer) // init with handle End
Sub Constructor(s as NSNetServiceMB) // put an existing service in a new object, e.g. to handle events End
Sub Constructor(domain as text, type as text, name as text) // This is the initializer for resolution. // If you know the domain, type and name of the service for which you wish to discover addresses, // you should initialize an NSNetService instance using this method and call resolve on the result. // If publish: is called on an NSNetService instance initialized with this method, // an NSNetServicesBadArgumentError will be sent in the error dictionary to the didNotPublish event. End
Sub Constructor(domain as text, type as text, name as text, port as integer) // This is the initializer for publishing. // You should use this initializer if you are going to announce the availability of a service on the network. // To publish a service in all available domains, pass the empty string as the domain. End
Sub Destructor() End
Function addresses(IPv4 as Boolean = true, IPv6 as Boolean = true) As text() // The addresses of the service. // pass IPv4 or IPv6 as false to filter list // In the event that no addresses are resolved for the service or the service has not yet been resolved, an empty array is returned. End
Sub publish() // Advertises a given service on the network. // This method returns immediately. Success or failure is indicated by callbacks to the NSNetService instance's delegate. // If the name of the service is the default name (""), then the service will be renamed automatically. // If the name of the service has been specified, then the service will not be renamed automatically. // If more control over renaming is required, then NSNetService.publishWithOptions is available. End
Sub publish(options as integer) // Advertises a given service on the network. // This method returns immediately. Success or failure is indicated by callbacks to the NSNetService events. // // See the notes above for NSNetServiceNoAutoRename for information about controlling the auto-renaming // behavior using this method. // When passed to publish options, this suppresses the auto-renaming of an // NSNetService in the event of a name collision. The collision is reported to the // didNotPublish event. // // NSNetServiceNoAutoRename = 1 // When passed to publish options, in addition to publishing the service, a // TCP listener is started for both IPv4 and IPv6 on the port specified by the // NSNetService. If the listening port can't be opened, an error is reported using // didNotPublish. Specify a port number of zero to use a random port. // When DidPublish is called, port will return the actual listening // port number. Since the listener only supports TCP, the publish will fail with // NSNetServicesBadArgumentError if the NSNetService type does not end with "_tcp". // New incoming connections will be delivered in the form of NSStreams via the // didAcceptConnectionWithInputStreamOutputStream event. // // NSNetServiceListenForConnections 2 // OS X 10.9 or iOS 7.0 and newer End
Sub resolve() // Attempts to determine at least one address for the NSNetService instance. // For applications linked on or after Mac OS X 10.4 "Tiger", this method calls // resolveWithTimeout with a value of 5.0. End
Sub resolve(timeout as Double) // Starts a resolve for the NSNetService instance of the specified duration. // If the DidResolveAddress event is called before the timeout expires, the resolve is successful. // If the timeout is reached, the DidNotResolve event will be called. // The value of the NSNetServicesErrorCode key in the error dictionary will be NSNetServicesTimeoutError. End
Sub startMonitoring() // Starts monitoring the NSNetService instance for events. // In Mac OS X 10.4 Tiger, monitored NSNetService instances inform their delegates of changes to the instance's TXT record by calling the DidUpdateTXTRecordData event. End
Sub stop() // Halts a service which is either publishing or resolving. End
Sub stopMonitoring() // Stops monitoring the NSNetService instance for events. End
Property Handle As Integer
End Class




Links
MBS FileMaker tutorial videos