ActiveXperts Network Component


ColdFusion UDP Sample Source Code

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 the 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 ColdFusion document

Create a new blank webdocument with the ".cfm" extention. First of all we are going to build the form whitch commands and properties of the device can be filled in. Then we are going to make a source code that connects to the device.

Step 3: Implementation

Establishing the connection and listing the files can be done in three steps:

  • Collect the ftp-server-address, the username and the password from the user
  • Establish the connection
  • List the files

Collecting the information can be done using a form. We've made our form look like this:

(Click on the picture to enlarge)

When we've got this information, we're ready to establish a connection to a server. First of all we need an object witch creates a connection between ColdFusion and the ActiveXperts software. To do that, use the following code:

<cfobject class="ax_AxNetwork.Udp" type="com" name="objUdp" Action="Create"> 

Once the object is created, we're able to use the component. We need to establish a connection, so we're going to use the Network Component method "connect()". Use the following code:


Now we need to list the files. The Network Component is able to get the first file in the folder using the "FindFirstFile()" method and then the next file using the "FindNextFile()" method. So we're going to list the first file in the folder first, then the next file (the second file) and than the next file (the third file) and so on. Use the following code:

objFiles = objUdp.FindFirstFile();
  writeoutput ("<tr>");
  writeoutput ("<td width=100>");        
  writeoutput ("</td>");
  writeoutput ("<td>");
  writeoutput(objFiles.Name & "<br>");        
  writeoutput ("</td>");
  writeoutput ("</tr>");                                
  objFiles = objUdp.FindNextFile();        
while(objUdp.LastError eq 0);

Perhaps you would like to show the content of another folder. Paste the following code, before the listing code.


We're displaying the results of the process using the "LastError" method of the Network Component. The method "LastError" displays a number. It's helpfull to know "0" means success. To get the error description use the "GetErrorDescription()" method. In our code we've used these methodes this way:

strResult = objUdp.LastError & " : " & objUdp.GetErrorDescription(objUdp.LastError);

It can be very helpfull to check for errors before executing some code. Applying this can be done easily:

if(objUdp.LastError eq "0"){
  Some code

Appendix: Full source code


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.