Quicklinks
The Domain Name System (DNS) is the method by which Internet addresses in mnemonic form - such as www.activexperts.com - are converted into the equivalent numeric IP address such as 212.97.55.136. To the user and application process this translation is a service provided either by the local host or from a remote host via the Internet. The DNS server (or resolver) may communicate with other Internet DNS servers if it cannot translate the address itself.
DNS names are constructed hierarchically. The highest level of the hierarchy is the last component or label of the DNS address.
Labels can be up to 63 characters long and are not case sensitive. A maximum length of 255 characters is allowed.
Labels must start with a letter and can only consist of letters, digits and hyphens.
Nslookup is a popular program for UNIX, LINUX and Windows to query Internet domain name servers. It allows the user to query name servers for information about various hosts and domains or to print a list of hosts in a domain.
ActiveSocket provides an easy-to-use development/scripting interface to use the same operations as NsLookup, through the DnsServer class. By using ActiveSocket, you can very easily create or enhance Windows applications/scripts with DNS lookup features.
ActiveSocket features the following: DNS, FTP, HTTP, HTTPs, ICMP Ping, IP-to-Country, MSN, NTP, RSH, SCP, SFTP, SNMP v1/v2c (Get, GetNext, Set), SNMP Traps, SNMP MIB, SSH, TCP, Telnet, TFTP, UDP, Telnet, Wake-On-LAN and more.
Download ActiveSocket from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.
First, create a new directory on the IIS Server's file system. This directory will hold the ASP later on.
From the 'Start menu', click on 'Administrative Tools' and click on 'Internet Information Services (IIS) Manager'. Right-click on the 'Web Sites' container and choose 'New->Web Site':
(Click on the picture to enlarge)
The 'Web Site Creation Wizard' is shown, guiding you thorugh the process of creating a new web site. Provide all necessary information:
You're now able to write an ASP script to use IP protocols with ActiveSocket.
First of all we need to create a form in HTML to get the login information for the ftp server. All we actually need is:
In this sample all we're going to do is create a ASP file that is able to list files and directories in a directory. Using ActiveSocket it is easy to create a page that makes you able to upload and to download files.
You can create a form that looks like this:
(Click on the picture to enlarge)
You can list files using ActiveSocket ftp in 3 steps.
Now that we have all the information we need, we need to create an object witch supports communicating through ActiveSocket. To do this we only need one line of code:
Set objFtp = Server.CreateObject( "ActiveXperts.FtpServer" )Connecting to the server
To connect to the server we're using the ActiveSocket method "Connect".
objFtp.connect request("server"), request("username"), request("password")
This makes a code look like this:
if request("submitbutton") <> "" then
dim objFiles
' create the object
Set objFtp = Server.CreateObject( "ActiveXperts.FtpServer" )
objFtp.clear
' set the logfile
objFtp.logfile = request("logfile")
' connect
objFtp.connect request("server"), request("username"), request("password")
objFtp.ChangeDir request("directory")
else
' do nothing
end if
If the previous actions have been succesfully executed, we can list the files. To list these files we're using two ActiveSocket methods:
When we know what the first file is we're starting a loop. If one file is listed, FindNextFile is used to move on to the next. If there is no more file, the software will return an error. Thats why we created the following code:
' find the first file if objFtp.LastError <> 0 then response.write("Connection failed..<br>") else set objFiles = objFtp.FindFirstFile() end if ' list the files if objFtp.LastError <> 0 then response.write("<tr><td>Sorry.. Failed to list the files..</td></tr>") else getfiles end if sub getfiles 'show the contents in a table response.write ("Files in directory " & request("directory") & " :") response.write ("<table>") 'the software will return an error if there is no more file to display, so: do while objFtp.LastError = 0 response.write("<tr>") response.write("<td>") 'display folders if objFiles.IsDirectory = 0 then response.write "File:" else response.write "Directory:" end if response.write("</td>") response.write("<td class=files>") 'display the names response.write(objFiles.name) response.write("</td>") response.write("</tr>") 'find the next file; continue the loop set objFiles = objFtp.FindNextFile loop response.write "</table>" end sub