ActiveSocket

 Product Overview

 ActiveSocket Objects:
 
 How to use

 Online Samples

 Download (.exe)

 Brochure (.pdf)

 Manual (.htm)

 Release Notes


Support

 Knowledge Base

 Forum

 Contact Support


Purchase

 Licensing

 Pricing

 Order now


Related documents

 Tutorials

 Tools


  Download ActiveSocket Network Communications Toolkit 4.1  (7643 KB - .exe file)
  Download Manual  (556 KB - .htm file)


ColdFusion SNMP Sample Source Code


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

ActiveSocket features the following: ICMP, HTTP and HTTPs with support for proxy servers and secure web sites, Telnet, NTP time protocol, RSH remote shell script interface, SNMP (Simple Network Management Protcol), SNMP Traps, Sockets (TCP and UDP), DNS, IP to Country Lookup, WOL (Wake-On-LAN), and more.

SNMP can be well integrated into ColdFusion environments.
This document describes how ActiveSocket's SNMP objects can be integrated into ColdFusion code.

ActiveSocket is compliant with SNMP v1 and SNMP v2c.
Different SNMP data types are supported, including:
  • String types (also called "octet strings");
  • Integer types (16bit, 32bit, 64bit and unsigned integers);
  • IP Address types;
  • Timetick types;
  • Counter types (32bit and 64bit counters);
  • OID types (also called "Object ID's");
  • Other, less frequently used datatypes.
The following operations are supported:
  • Get - retrieve an object variable from the (remote) agent;
  • GetNext - retrieve the next object variable from a table or list within an agent;
  • Set - set values for object variables within an agent.


Step 1: Download and install the ActiveSocket Toolkit

Download ActiveSocket 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

For the usage of SNMP in ColdFusion, we're going to work with objects. Sending an OID to a server is quit simple. It can be done in four simple steps.

  • Make the ActiveSocket object
  • Fill in the properties
  • Connect to the host
  • Send the OID

Attention: Before using this sample, make sure you've configured SNMP properly.

Once the object is created the rest is easy. To make the ActiveSocket object in ColdFusion you need the following code snippet:

 <cfobject class="ActiveXperts.SnmpManager" type="com" name="objSnmp" Action="Create"> 

Trough this tag you are able to communicate trough the ActiveSocket toolkit. The program has a certain amount of options witch are to be found in the products manual that is shipped with it. In our sample just a few of them are used. You can call to a function of the object using a “.”.

We're also going to need a form that collects the required information to send an OID. We've made a form that looks like this:


    
    (Click on the picture to enlarge)

Once the form is ready the first thing we're configuring is the “logfile” option. You can fill in the path and filename for the logfile. Trough this file you’re able to check what goes on during the execution of the script you are writing. Use the following code to configure the logfile:

 <cfset objSnmpManager.LogFile = “C:\temp\logfile.txt”> 

First of all we're going to initialise SNMP. Using "Initialize()":

 <cfset objSnmpManager.Initialize()> 

Then we're moving on to setting the protocol version. We're doing this with the "version" property of the object we have created. Versions can differ between version one and two.

 <cfset objSnmpManager.Version = URL.Version > 

If all of this is succesfully configured, we're able to open a connection to a host. We're able to do that using the "Open()" command. We need to fill in the host, the community and the portnumber.

 <cfset objSnmpManager.Open("localhost", "public", 161) > 

You're able to get an OID using the property "Get("someOid")". This makes the entire sourcecode to send an OID look like this:


function snmpget(getnext, OID){

   objSnmpManager.LogFile = strLogFile;
   objSnmpManager.Initialize();
   objSnmpManager.ProtocolVersion = strVersion;
   
   if(objSnmpManager.LastError eq 0){
      objSnmpManager.Open(strHost,strCommunity,strPort);
   }

   if(objSnmpManager.LastError eq 0){
     objSnmpData = objSnmpManager.get(OID);
     if (getnext eq "getnext") {
       objSnmpData = objSnmpManager.getnext();
     }
	   
   }
	 
   if(objSnmpManager.LastError eq 0){

     strOid = objSnmpData.oid;
     strValue = objSnmpData.value & "<br>";
		 
   }

   strResult = objSnmpManager.LastError & " : " & objSnmpManager.GetErrorDescription(objSnmpManager.LastError);
	 
   objSnmpManager.Close();
   objSnmpManager.Shutdown();	 

}

There are many working samples included with the product. You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/asocket.





The ActiveSocket tool is a Network Communications ActiveX software component (SDK). This control supports SNMP, SMTP, POP3, Telnet, TCP, NTP, RSH, HTTP, HTTPs, FTP, DNS, ICMP and more, and can be used by any Windows development platform, including Visual Basic .NET, Visual CSharp .NET, ASP .NET (VB,CS), ASP, Visual Basic, Visual Studio/Visual C++, Delphi, PHP, ColdFusion, HTML, VBScript and any other ActiveX/COM compliant platform. The ActiveSocket Toolkit is an ActiveXperts Software B.V. Product.

©2009 ActiveXperts Software B.V. All rights reserved.  Contact Us | Terms of Use | Privacy Policy