SocketTools .NET Edition

DnsClient.Query Method 

Perform a general nameserver query for a specific type of record.

[Visual Basic]
Public Function Query( _
   ByVal hostName As String, _
   ByVal recordType As RecordType, _
   ByRef recordData As String _
) As Boolean
[C#]
public bool Query(
   string hostName,
   RecordType recordType,
   ref string recordData
);

Return Value

A boolean value which specifies if the method was successful or not. A return value of True indicates that the method call completed successfully. A return value of False indicates that the method failed and the application should check the value of the LastError property.

Remarks

The Query method performs a general nameserver query for a given record based on the name and type. This method will not use a local host file when performing host name or address queries.

To resolve a hostname into an Internet address, it is recommended that you use the Resolve method.

Example

The following example queries a nameserver for the TXT record for the specified remote host. If a record is found, its value will be displayed in a message box.

[Visual Basic]
Dim strRecord As String
 
If dnsClient.Query(TextBox1.Text, RecordType.dnsRecordTXT, strRecord) Then
    MsgBox(strRecord, MsgBoxStyle.Information)
End If
    

See Also

DnsClient Class | SocketTools Namespace | HostAddress Property | HostName Property | Resolve Method