ZeroConfService

Overview

The ZeroConfService class holds information about discovered services. In the Remoting SDK this class is used by other classes from the RemObjects.SDK.ZeroConf namespace to manipulate information about discovered services. For example the ZeroConfBrowser class uses instances of the ZeroConfService class to hold a list of discovered services (see the ZeroConfBrowser property).

Use Case

This class can be used to gain access to specific information about a discovered service. The example below shows how to use this class to resolve a domain as well as a service type and name to a real address and port.

private void zeroConfBrowser_ServiceAdded(object sender, RemObjects.SDK.ZeroConf.ZeroConfBrowseResultArgs args)
{
    ZeroConfService serv = args.Record;            
    LogMessage(String.Format("Discovered new service: {0}", serv.Name));
    if (serv.TryResolve())
        LogMessage(String.Format("Service resolved. Host name: {0} Port number: {1}", 
                serv.HostTarget.Replace(LOCAL_SUFFIX, String.Empty), serv.Port));
    else 
        LogMessage("Service resolve failed!");
}

Note: Take a look at the Bonjour Discovery Sample (.NET) shipped with the Remoting SDK to see service discovery in action.

Location

  • Reference: RemObjects.SDK.ZeroConf.dll
  • Namespace: RemObjects.SDK.ZeroConf
  • Platforms: .NET Core, .NET Framework, .NET Standard


 

constructor

Creates a new instance of the ZeroConfService class.

 

constructor(domain: String; name: String; type: String)

 

ZeroConfService(String domain, String name, String type)

 

init(_ domain: String, _ name: String, _ type: String)

 

Sub New(domain As String, name As String, type As String)

Parameters:

  • domain: Service domain name
  • name: Service name
  • type: Type name of the service

Addresses

Gets a list of the server IP addresses. If the host is not resolved yet a DNSServiceException exception will be raised while accessing this property.

 

property Addresses: array of IPAddress read write;

 

IPAddress[] Addresses { get; set; }

 

var Addresses: IPAddress... { get{} set{} }

 

Property Addresses() As IPAddress()

BeginResolve (AsyncCallback, Object): IAsyncResult

Begins to asynchronously resolve a domain as well as a service type and name to a real address and port with a 10 second timeout.

 

method BeginResolve(callback: AsyncCallback; state: Object): IAsyncResult

 

IAsyncResult BeginResolve(AsyncCallback callback, Object state)

 

func BeginResolve(_ callback: AsyncCallback, _ state: Object) -> IAsyncResult

 

Function BeginResolve(callback As AsyncCallback, state As Object) As IAsyncResult

Parameters:

  • callback: Callback method that will be called once the resolve operation is completed.
  • state: Object containing state information for this request

BeginResolve (TimeSpan, AsyncCallback, Object): IAsyncResult

Begins to asynchronously resolve a domain as well as a service type and name to a real address and port with a provided timeout.

 

method BeginResolve(timeout: TimeSpan; callback: AsyncCallback; state: Object): IAsyncResult

 

IAsyncResult BeginResolve(TimeSpan timeout, AsyncCallback callback, Object state)

 

func BeginResolve(_ timeout: TimeSpan, _ callback: AsyncCallback, _ state: Object) -> IAsyncResult

 

Function BeginResolve(timeout As TimeSpan, callback As AsyncCallback, state As Object) As IAsyncResult

Parameters:

  • timeout: Resolve operation timeout
  • callback: Callback method that will be called once the resolve operation is completed.
  • state: Object containing state information for this request

CheckResolved  protected

Checks if the service is already resolved. Raises the DNSServiceException exception if the service is not resolved yet.

This method is called in the property getter methods of this class.

 

method CheckResolved

 

void CheckResolved()

 

func CheckResolved()

 

Sub CheckResolved()

Domain

Gets the service domain.

 

property Domain: String read;

 

String Domain { get; }

 

var Domain: String { get{} }

 

ReadOnly Property Domain() As String

EndResolve

Ends a pending asynchronous resolve operation.

 

method EndResolve(ar: IAsyncResult)

 

void EndResolve(IAsyncResult ar)

 

func EndResolve(_ ar: IAsyncResult)

 

Sub EndResolve(ar As IAsyncResult)

Parameters:

  • ar: IAsyncResult that stores state information

FullDomainName

Gets the full domain name of the service.

If the service is not resolved yet then accessing this property will result in a DNSServiceException exception.

 

property FullDomainName: String read write;

 

String FullDomainName { get; set; }

 

var FullDomainName: String { get{} set{} }

 

Property FullDomainName() As String

HostTarget

Gets the server host name.

If the service is not resolved yet then accessing this property will result in a DNSServiceException exception.

 

property HostTarget: String read write;

 

String HostTarget { get; set; }

 

var HostTarget: String { get{} set{} }

 

Property HostTarget() As String

Name

Gets the server name.

 

property Name: String read;

 

String Name { get; }

 

var Name: String { get{} }

 

ReadOnly Property Name() As String

Port

Gets the port that is used by the remote server that hosts the current service.

If the service is not resolved yet then accessing this property will result in a DNSServiceException exception.

 

property Port: Int32 read write;

 

Int32 Port { get; set; }

 

var Port: Int32 { get{} set{} }

 

Property Port() As Int32

Resolve

Resolves a domain as well as a service type and name to a real address and port with a 10 second timeout. If the resolve operation was terminated by timeout or if the server returns an error, a ZeroConfException exception will be raised.

 

method Resolve

 

void Resolve()

 

func Resolve()

 

Sub Resolve()

Resolve (TimeSpan)

Resolves a domain as well as a service type and name to a real address and port with a provided timeout. If the resolve operation was terminated by timeout or if the server returns an error, a ZeroConfException exception will be raised.

 

method Resolve(timeout: TimeSpan)

 

void Resolve(TimeSpan timeout)

 

func Resolve(_ timeout: TimeSpan)

 

Sub Resolve(timeout As TimeSpan)

Parameters:

  • timeout: Resolve operation timeout

Resolved

Gets a flag indicating whether the server adress and port are already resolved.

 

property Resolved: Boolean read write;

 

Boolean Resolved { get; set; }

 

var Resolved: Boolean { get{} set{} }

 

Property Resolved() As Boolean

TryResolve

Tries to resolve a domain as well as a service type and name to a real address and port with a 10 second timeout. If the resolve operation was terminated by timeout or if the server returns an error, this method will return false.

 

method TryResolve: Boolean

 

Boolean TryResolve()

 

func TryResolve() -> Boolean

 

Function TryResolve() As Boolean

TryResolve (TimeSpan): Boolean

Tries to resolve a domain as well as a service type and name to a real address and port with a provided timeout. If the resolve operation was terminated by timeout or if the server returns an error, this method will return false.

 

method TryResolve(timeout: TimeSpan): Boolean

 

Boolean TryResolve(TimeSpan timeout)

 

func TryResolve(_ timeout: TimeSpan) -> Boolean

 

Function TryResolve(timeout As TimeSpan) As Boolean

Parameters:

  • timeout: Resolve operation timeout

TxtRecord

Gets a dictionary with additional information about the server.

If the service is not resolved yet then accessing this property will result in a DNSServiceException exception.

 

property TxtRecord: IDictionary<String, array of Byte> read write;

 

IDictionary<String, array of Byte> TxtRecord { get; set; }

 

var TxtRecord: IDictionary<String, array of Byte> { get{} set{} }

 

Property TxtRecord() As IDictionary<String, array of Byte>

TxtRecordStr

Gets a dictionary with additional information about the server. This dictionary contains the same values as the TxtRecord dictionary except that values contained there are converted into strings.

If the service is not resolved yet then accessing this property will result in a DNSServiceException exception.

 

property TxtRecordStr: IDictionary<String, String> read write;

 

IDictionary<String, String> TxtRecordStr { get; set; }

 

var TxtRecordStr: IDictionary<String, String> { get{} set{} }

 

Property TxtRecordStr() As IDictionary<String, String>

Type

Gets the service type name.

 

property Type: String read;

 

String Type { get; }

 

var Type: String { get{} }

 

ReadOnly Property Type() As String

 

Addresses

Gets a list of the server IP addresses. If the host is not resolved yet a DNSServiceException exception will be raised while accessing this property.

 

property Addresses: array of IPAddress read write;

 

IPAddress[] Addresses { get; set; }

 

var Addresses: IPAddress... { get{} set{} }

 

Property Addresses() As IPAddress()

Domain

Gets the service domain.

 

property Domain: String read;

 

String Domain { get; }

 

var Domain: String { get{} }

 

ReadOnly Property Domain() As String

FullDomainName

Gets the full domain name of the service.

If the service is not resolved yet then accessing this property will result in a DNSServiceException exception.

 

property FullDomainName: String read write;

 

String FullDomainName { get; set; }

 

var FullDomainName: String { get{} set{} }

 

Property FullDomainName() As String

HostTarget

Gets the server host name.

If the service is not resolved yet then accessing this property will result in a DNSServiceException exception.

 

property HostTarget: String read write;

 

String HostTarget { get; set; }

 

var HostTarget: String { get{} set{} }

 

Property HostTarget() As String

Name

Gets the server name.

 

property Name: String read;

 

String Name { get; }

 

var Name: String { get{} }

 

ReadOnly Property Name() As String

Port

Gets the port that is used by the remote server that hosts the current service.

If the service is not resolved yet then accessing this property will result in a DNSServiceException exception.

 

property Port: Int32 read write;

 

Int32 Port { get; set; }

 

var Port: Int32 { get{} set{} }

 

Property Port() As Int32

Resolved

Gets a flag indicating whether the server adress and port are already resolved.

 

property Resolved: Boolean read write;

 

Boolean Resolved { get; set; }

 

var Resolved: Boolean { get{} set{} }

 

Property Resolved() As Boolean

TxtRecord

Gets a dictionary with additional information about the server.

If the service is not resolved yet then accessing this property will result in a DNSServiceException exception.

 

property TxtRecord: IDictionary<String, array of Byte> read write;

 

IDictionary<String, array of Byte> TxtRecord { get; set; }

 

var TxtRecord: IDictionary<String, array of Byte> { get{} set{} }

 

Property TxtRecord() As IDictionary<String, array of Byte>

TxtRecordStr

Gets a dictionary with additional information about the server. This dictionary contains the same values as the TxtRecord dictionary except that values contained there are converted into strings.

If the service is not resolved yet then accessing this property will result in a DNSServiceException exception.

 

property TxtRecordStr: IDictionary<String, String> read write;

 

IDictionary<String, String> TxtRecordStr { get; set; }

 

var TxtRecordStr: IDictionary<String, String> { get{} set{} }

 

Property TxtRecordStr() As IDictionary<String, String>

Type

Gets the service type name.

 

property Type: String read;

 

String Type { get; }

 

var Type: String { get{} }

 

ReadOnly Property Type() As String

 

constructor

Creates a new instance of the ZeroConfService class.

 

constructor(domain: String; name: String; type: String)

 

ZeroConfService(String domain, String name, String type)

 

init(_ domain: String, _ name: String, _ type: String)

 

Sub New(domain As String, name As String, type As String)

Parameters:

  • domain: Service domain name
  • name: Service name
  • type: Type name of the service

BeginResolve (AsyncCallback, Object): IAsyncResult

Begins to asynchronously resolve a domain as well as a service type and name to a real address and port with a 10 second timeout.

 

method BeginResolve(callback: AsyncCallback; state: Object): IAsyncResult

 

IAsyncResult BeginResolve(AsyncCallback callback, Object state)

 

func BeginResolve(_ callback: AsyncCallback, _ state: Object) -> IAsyncResult

 

Function BeginResolve(callback As AsyncCallback, state As Object) As IAsyncResult

Parameters:

  • callback: Callback method that will be called once the resolve operation is completed.
  • state: Object containing state information for this request

BeginResolve (TimeSpan, AsyncCallback, Object): IAsyncResult

Begins to asynchronously resolve a domain as well as a service type and name to a real address and port with a provided timeout.

 

method BeginResolve(timeout: TimeSpan; callback: AsyncCallback; state: Object): IAsyncResult

 

IAsyncResult BeginResolve(TimeSpan timeout, AsyncCallback callback, Object state)

 

func BeginResolve(_ timeout: TimeSpan, _ callback: AsyncCallback, _ state: Object) -> IAsyncResult

 

Function BeginResolve(timeout As TimeSpan, callback As AsyncCallback, state As Object) As IAsyncResult

Parameters:

  • timeout: Resolve operation timeout
  • callback: Callback method that will be called once the resolve operation is completed.
  • state: Object containing state information for this request

CheckResolved  protected

Checks if the service is already resolved. Raises the DNSServiceException exception if the service is not resolved yet.

This method is called in the property getter methods of this class.

 

method CheckResolved

 

void CheckResolved()

 

func CheckResolved()

 

Sub CheckResolved()

EndResolve

Ends a pending asynchronous resolve operation.

 

method EndResolve(ar: IAsyncResult)

 

void EndResolve(IAsyncResult ar)

 

func EndResolve(_ ar: IAsyncResult)

 

Sub EndResolve(ar As IAsyncResult)

Parameters:

  • ar: IAsyncResult that stores state information

Resolve

Resolves a domain as well as a service type and name to a real address and port with a 10 second timeout. If the resolve operation was terminated by timeout or if the server returns an error, a ZeroConfException exception will be raised.

 

method Resolve

 

void Resolve()

 

func Resolve()

 

Sub Resolve()

Resolve (TimeSpan)

Resolves a domain as well as a service type and name to a real address and port with a provided timeout. If the resolve operation was terminated by timeout or if the server returns an error, a ZeroConfException exception will be raised.

 

method Resolve(timeout: TimeSpan)

 

void Resolve(TimeSpan timeout)

 

func Resolve(_ timeout: TimeSpan)

 

Sub Resolve(timeout As TimeSpan)

Parameters:

  • timeout: Resolve operation timeout

TryResolve

Tries to resolve a domain as well as a service type and name to a real address and port with a 10 second timeout. If the resolve operation was terminated by timeout or if the server returns an error, this method will return false.

 

method TryResolve: Boolean

 

Boolean TryResolve()

 

func TryResolve() -> Boolean

 

Function TryResolve() As Boolean

TryResolve (TimeSpan): Boolean

Tries to resolve a domain as well as a service type and name to a real address and port with a provided timeout. If the resolve operation was terminated by timeout or if the server returns an error, this method will return false.

 

method TryResolve(timeout: TimeSpan): Boolean

 

Boolean TryResolve(TimeSpan timeout)

 

func TryResolve(_ timeout: TimeSpan) -> Boolean

 

Function TryResolve(timeout As TimeSpan) As Boolean

Parameters:

  • timeout: Resolve operation timeout