PowerTCP Server for ActiveXfrom $499.00
DnsServer ActiveX Control
Use the DnsServer control to build a DNS server application which responds to DNS queries. Features include:
- When a request is received, a corresponding event is raised. Write your own custom handling code in the event handler.
- The GetAddress event is raised when a client requests a domian name be resolved to a dot address (forward lookup).
- The GetName event is raised when a client requests a dot address be resolved to a domain name (reverse lookup).
- The GetMailServer event is raised when a client requests an email address be resolved to the mail server responsible for that email address (mx lookup).
- Use with the Dns control to build a "proxy" DNS server (passing on requests to another DNS server), or resolve names using a local datasource.
- Visual Studio .NET (.NET Framework)
- Visual Basic (VB)
- Visual C++ (VC++)
- Office 97/2000
|ClientException is used only in the GetAddress, GetName, and GetMailServer events. After the event is fired, the DnsServer Control will expect this property to be set if you wish to return an error condition to the client. The default value is dnsOk.
|Returns the address in use while the socket is active and an empty string when the UDP socket is closed.
|Returns the port number in use while the socket is active and 0 when the socket is closed. When the Protocol property of the UDP Control is not ptUdp, LocalPort returns 0.
|Controls the blocking behavior of methods that can be used in blocking and non-blocking ways.
|Abort any blocking method and release all system resources.
|Show the About Box.
|Release system resources.
|Allocate a socket for sending and receiving datagrams.
|Start or stop the accumulation of trace or debug data. Once started, this method accumulates data until it is turned off.
|Fires when an error condition occurs.
|Fires when a DNS type A request has been received.
|Fires when a DNS type MX request has been received.
|Fires when a DNS type PTR request has been received.
How easy is the DnsServer control to use? Check out the VB examples below, which demonstrates responding to a request to resolve an address.
' Don't forget to add a reference to Microsoft Scripting Runtime.
Dim LookupTable As New Dictionary
Private Sub StartServer()
' Start the server
' Initialize the "phony" lookup table (replace this with a real data source)
LookupTable.Add "127.0.0.1", "localhost"
LookupTable.Add "188.8.131.52", "myserver.com"
LookupTable.Add "184.108.40.206", "dart.com"
Private Sub DnsServer1_GetName(ByVal Address As String, ByVal Names As
DartDnsServerCtl.IDartStrings, OwnerName As String, ByVal Request As
' Check if they are requesting a recursive search or a local search. This example
only handles local
' searches, so send an exception if it is recursive.
If Not Cbool(Request.RecursiveFlag) Then
' Look up the name
Dim Name As String
Name = MyGetHostName(Address)
' See if a valid name was found.
If Name <> "" Then
' Add the name to the response
' The owner is the local server.
OwnerName = DnsServer1.LocalAddress
' Name not found. Return a not found exception.
DnsServer1.ClientException = dnsNameError
' Uh oh, this server does local lookups only
DnsServer1.ClientException = dnsNotImplemented
Private Function MyGetHostName(ByVal Name As String)
' Use the LookupTable to get the name from the IP.
If LookupTable.Exists(Address) Then
MyGetHostName = LookupTable.Item(Address)
MyGetHostName = ""