Contact Info

Crumbtrail » Network Component » How to Use Network Component » WOL (Wake-On-LAN) » Classic ASP

ASP 2.x UDP Sample Source Code in ASP

Network Component provides an easy-to-use development interface to a variety of IP protocols. By using Network Component, you can very easily create or enhance applications with network features.

Network Component 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.

Network Component can be well integrated into any development platform that supports ActiveX objects.

Step 1: Download and install Network Component

Download Network Component from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.

Step 2: Create a new Web Site

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 Network Component.

Step 3: Create the from

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 Network Component 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)

Step 4:Create ActiveXperts Network Component objects in ASP

Create a new ASP script called DEFAULT.ASP in the directory that was created in Step2, using your favorite editor. On top of the ASP code, insert the following lines to declare and create the Dns object:

<object runat="server" progid="AxNetwork.Udp"  id="objUdp"></object>
<object runat="server" progid="AxNetwork.ASConstants" id="objConstants"></object>

Step 5: Test a small piece of ASP

Now, test if your new web site is working well with ActiveXperts Network Component using your browser. If you are using Microsoft Internet Explorer, it is recommended to disable friendly error message because this default setting doesn't show any ASP error message, making it hard to debug if there are any problems:

Now, use the following piece of code in your DEFAULT.ASP page and test it into your favourite browser:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

<html xmlns="" >
    <title>ActiveXperts Network Component ASP Demo</title>
    <object runat="server" progid="AxNetwork.Udp" id="objUdp"></object>
    <object runat="server" progid="AxNetwork.Constants" id="objConstants"></object>

    <title>Network Component Demo</title>
     Network Component version: <% = objSmtp.Version %>
     <br />
     Network Component License Status: <% = objSmtp.LicenseStatus %>

Appendix: Full source code

<object runat="server" progid="AxNetwork.WOL" id="objWOL"> </object>

' HTML-CSS layout includes below, no code there!
<!-- #include file="css/Header.html" -->
<!-- #include file="css/Menu.html" -->

  ' A license key is required to unlock this component after the trial period has expired.
  ' Call 'Activate' with a valid license key as its first parameter. Second parameter determines whether to save the license key permanently 
  ' to the registry (True, so you need to call Activate only once), or not to store the key permanently (False, so you need to call Activate
  ' every time the component is created). For details, see manual, chapter "Product Activation".
  ' objWOL.Activate "XXXXX-XXXXX-XXXXX", False    

  Dim numLastError, strLastError

  Set fso = CreateObject("Scripting.FileSystemObject")
  strLogfile = fso.GetSpecialFolder(2) & "\Wol.log"

  strLastError                = ""

  If( Request( "btnSubmit" ) <> "" ) Then

    objWOL.LogFile = Request( "txtLogFile" )   ' Optional: set LogFile property for troubleshooting purposes
    objWOL.WakeUp Request( "txtMac" )
    numLastError             =  objWOL.LastError
    strLastError             =  numLastError & ": " & objWOL.GetErrorDescription( numLastError )  
  End If


  <h1>ActiveXperts Network Component ASP Sample - Wake On LAN</h1>

  <form action="wakeonlan.asp" method="post">
    <h3>Module [<% = objWOL.Module %>]; Build [<% = objWOL.Build %>]</h3>
    <!-- MAC Address -->
    <label for="MACAddress">MAC Address</label>
      <input type="text" name="txtMac" value=<% If Request( "txtMac" ) = "" Then %>"00-10-4B-BA-7A-51"<% Else %><% = Request( "txtMac" ) %><% End If %>>
    <!-- WakeUp! Button -->
      <input type="submit" value="Wake Up!" name="btnSubmit">
    <!-- Emty Row -->

    <!-- Logfile -->
    <label for="Logfile">Logfile:</label>
      <input type="text" id="LogFile" name="txtLogFile" value="<% = strLogfile %>" />
    <!-- Result code -->
    <label for="Result">Result code:</label>
        <input type="text" id="Result" name="txtResult" style="font-weight: bold;" value="<% = strLastError %>" />
    <br />
    <br />
    This sample is based on ActiveXperts Network Component, an<a href="" target="_blank">ActiveXperts Software</a> product.<br />
    <a href="Default.asp">Back to main page</a>
</div><!-- /container -->
' HTML-CSS layout include below, no code there!
<!-- #include file="css/Footer.html" -->

You can download the complete sample on our FTP site There are many other working Network Component scripts on our site and shipped with the product.