ActiveXperts Network Communication Toolkit Manual

© 2009 ActiveXperts Software B.V.  contact@activexperts.com

 

Table of Contents

PART I: Getting Started

  1. Introduction
  2. System Requirements
  3. Installation
  4. How to use the ActiveSocket objects

PART II: Objects

  1. Icmp object
  2. Tcp object
  3. Udp object
  4. Http object
  5. FtpServer / FtpFile objects
  6. TftpServer object
  7. DnsServer / DnsRecord objects
  8. Ssh object
  9. Rsh object
  10. Ntp object
  11. SnmpManager / SnmpObject objects
  12. SnmpTrapManager / SnmpTrap objects
  13. SnmpMibBrowser object
  14. IPtoCountry object
  15. Msn object
  16. Wake-On-LAN (WOL) object

PART V: Support, Licensing

  1. Constants and Error Codes
  2. Support
  3. Purchase and product activation
  4. Appendix A: License Agreement

1. Introduction

1.1. What is ActiveSocket?

Adding network communications capabilities to an application is not a simple matter. It requires specialized knowledge that might be outside an individual programmer's expertise. For years, VBScript, Visual Basic and Visual C++ developers have relied upon the power, flexibility and reliability of the ActiveSocket Network Communication Toolkit from ActiveXperts Software. And today, also .NET developers use this control.

With ActiveSocket you can communicate across IP networks, including the Internet. ActiveSocket provides an easy-to-use scripting interface for IP communications. By using ActiveSocket, you can very easily create or enhance applications with network features.

Use ActiveSocket to integrate the following IP protocols in your application or script:

ActiveSocket can be used by any of the following operating systems:

ActiveSocket Toolkit can be used by any of the following development languages:

1.2. ActiveSocket Architecture

The core of ActiveSocket Toolkit is an ActiveX/COM component that comes in a 32-bit and a 64-bit version:

ActiveSocket can be distributed easily to any server and workstation in your network 9required a Processional License, see also Click here for more information about the installation.

2. System requirements

2.1. Supported Operating Systems

ActiveSocket Toolkit can be used by any of the following operating systems:

NOTE: On 64 bits systems, you can run 32- and 64 bit programs. To integrate ActiveSocket in a 64-bit (web) application of service, use the 64-bit ASocketx64.dll. To integrate ActiveSocket in a 32-bit (web) application of service, use the 32-bit ASocket.dll.

2.2. Supported Development Platforms

The ActiveSocket Toolkit can be used by any of the following programming languages:

3. Installation

The ActiveSocket Toolkit package consists of 3 components; any combination of components can be installed:

3.1. Installation on a single computer

Simply run the ASOCKET.EXE Setup program. The InstallShield wizard will guide you through the rest of the setup.
If you choose the ActiveSocket Toolkit COM component, the Setup program can perform the registration of the COM component for you. But it will also give you the opportunity to register the object yourself.

Any subsequent installation of ActiveSocket Toolkit can be performed either manually or by using the Setup program.

3.2. Installation on multiple computers

Any subsequent installations can be performed using the setup program.
But since the installation of the core components is very simple, you may want to do it manually, or integrate it into your companies software distribution program.

If you choose to install the COM component manually on other machines, simply perform the following actions:

4. How to use ActiveSocket

4.1. Introduction

The following code snippets (VBScript) illustrate how to use various ActiveSocket objects.

ICMP sample (ping a remote host)
Set objIcmp = CreateObject("ActiveXperts.Icmp")                 ' Create new Icmp instance
For i = 1 To 4                                                  ' Prepare for 4 consecutive pings
  objIcmp.Ping "www.activexperts.com", 2000                     ' Ping host (time-out: 2000 msecs)
  If( objIcmp.LastError = 0 ) Then
     WScript.Echo "Reply from " & strHost & _                   ' Display Ping results
                  ": time=" & objIcmp.LastDuration & "ms" & _   ' Display Duration
                  " TTL=" & objIcmp.LastTtl                     ' Display TTL
  Else
     WScript.Echo "Error " & objIcmp.LastError
  End If
Next
HTTP sample (read a web page)
Set objHttp = CreateObject( "ActiveXperts.Http" )               ' Create new Http instance
objHttp.ProxyServer   = "proxy01.intranet.dom"                  ' Proxy server  - if required
objHttp.ProxyAccount  = "mjackson"                              ' Proxy authentication
objHttp.ProxyPassword = "mjackson1"                             ' Proxy authentication
objHttp.Connect( "www.activexperts.com/products" )              ' Connect to a web server
WScript.Echo "Connect, result: " & objHttp.LastError
If( objHttp.LastError <> 0 ) Then
 WScript.Quit
End If
strData = objHttp.ReadData                                      ' Read web page data
WScript.Echo "ReadData, result: " & objHttp.LastError
If( objHttp.LastError <> 0 ) Then
 WScript.Echo strData                                           ' Display web page data
End If
objHttp.Disconnect
FTP sample (list files in a specific directory on an FTP server)
Set objFtpServer = CreateObject ( "ActiveXperts.FtpServer" )

objFtpServer.Connect "ftp.activexperts-labs.com","anonymous","" ' Connect to the FTP server 
Wscript.Echo "Connect, result: " & objFtpServer.LastError
If( objFtpServer.LastError <> 0 ) Then                          ' If connect failed then quit
  WScript.Quit
End If

objFtpServer.ChangeDir "samples/ASocket/Visual Basic/Telnet"    ' Change directory
Wscript.Echo "ChangeDir, result: " & objFtpServer.LastError
If( objFtpServer.LastError <> 0 ) Then                          ' If ChangeDir fails then disconnect and quit
  objFtpServer.Disconnect
  WScript.Quit
End If

Set objFtpFile = objFtpServer.FindFirstFile()                   ' Iterate over all files; start with the first one
While( objFtpServer.LastError = 0 )
  WScript.Echo "Name: " & objFtpFile.Name                       ' Display file name
  WScript.Echo "IsDirectory: " & objFtpFile.IsDirectory         ' Display directory or file
  WScript.Echo "Size: " & objFtpFile.Size                       ' Display file size
  WScript.Echo "Date: " & objFtpFile.Date                       ' Display file date
   
  ' To save the file, call the GetFile function. 
  ' strSaveAs = "C:\temp\" & objFtpFile.Name
  ' objFtpServer.GetFile objFtpFile.Name, strSaveAs
  ' Wscript.Echo "Save file, result: " & objFtpServer.LastError

  ' To delete a file, call the DeleteFile function. 
  ' objFtpServer.DeleteFile objFtpFile.Name
  ' Wscript.Echo "Delete, result: " & objFtpServer.LastError

  Set objFtpFile = objFtpServer.FindNextFile()                  ' Next file
Wend

objFtpServer.Disconnect                                         ' Disconnect
TFTP sample (download a file from a remote TFTP host, save it locally)
Set objTftpServer = CreateObject ( "ActiveXperts.TftpServer" ) 

objTftp.Get "10.1.1.10", "/folder1/file.txt", "c:\\file.txt"    ' Download file, save it locally 
Wscript.Echo "Get, result: " & objTftp.LastError 
If( objTftp.LastError <> 0 ) Then                               ' If download failed then quit
  WScript.Quit
End If

WScript.Echo "Packets received: " & objTftp.PacketsReceived     ' Print download statistics
WScript.Echo "Bytes received: " & objTftp.BytesReceived         ' Print download statistics
DNS sample (list all records for a specific domain)
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")     ' Create object
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Host       = "ns1.interstroom.nl"                  ' DNS server
      
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY ' Show all DNS records for activexperts.com
WScript.Echo "Lookup, result: " & objDnsServer.LastError    
If( objDnsServer.LastError <> 0 ) Then
   WScript.Quit
End If

If ( objDnsServer.IsAuthoritative = True ) Then
   WScript.Echo "Server is an authority for this domain"
Else
   WScript.Echo "Server is not an authority for this domain"
End If
   
Set objDnsRecord = objDnsServer.GetFirstRecord                  ' Iterate over all DNS records; get first record
While ( objDnsServer.LastError = 0 )
   Select Case objDnsRecord.Type 
     Case objConstants.asDNS_TYPE_A
       WScript.Echo "Type             : A"
       WScript.Echo "Name             : " & objDnsRecord.Name
       WScript.Echo "IPv4 Address     : " & objDnsRecord.Address
     Case objConstants.asDNS_TYPE_AAAA
       WScript.Echo "Type             : AAAA"
       WScript.Echo "Name             : " & objDnsRecord.Name
       WScript.Echo "IPv6 Address     : " & objDnsRecord.Address
     Case objConstants.asDNS_TYPE_CNAME
       WScript.Echo "Type             : CNAME"
       WScript.Echo "Name             : " & objDnsRecord.Name
       WScript.Echo "Alias            : " & objDnsRecord.Address
     Case objConstants.asDNS_TYPE_MX 
       WScript.Echo "Type             : MX"
       WScript.Echo "Name             : " & objDnsRecord.Name
       WScript.Echo "Preference       : " & objDnsRecord.Preference
       WScript.Echo "Mail Exchange    : " & objDnsRecord.MailExchange
     Case objConstants.asDNS_TYPE_NS
       WScript.Echo "Type             : NS"
       WScript.Echo "Name             : " & objDnsRecord.Name
       WScript.Echo "Name Server      : " & objDnsRecord.NameServer
     Case objConstants.asDNS_TYPE_PTR
       WScript.Echo "Type             : PTR"
       WScript.Echo "Name             : " & objDnsRecord.Name
       WScript.Echo "Host             : " & objDnsRecord.Address
     Case objConstants.asDNS_TYPE_SOA
       WScript.Echo "Type             : SOA"
       WScript.Echo "Name             : " & objDnsRecord.Name
       WScript.Echo "Name Server      : " & objDnsRecord.NameServer
       WScript.Echo "MailBox          : " & objDnsRecord.MailBox
       WScript.Echo "Serial           : " & objDnsRecord.SerialNumber
       WScript.Echo "Refresh          : " & objDnsRecord.RefreshInterval
       WScript.Echo "Retry Interval   : " & objDnsRecord.RetryInterval
       WScript.Echo "Expiration Limit : " & objDnsRecord.ExpirationLimit
       WScript.Echo "Minimum TTL      : " & objDnsRecord.MinimumTTL
   End Select

   WScript.Echo "TTL              : " & objDnsRecord.TTL
   WScript.Echo
  
   Set objDnsRecord = objDnsServer.GetNextRecord                ' Iterate over all DNS records; get next record
Wend
SSH sample (run a command on a remote LINUX/UNIX host in a secure way)
Set objSsh           = CreateObject("ActiveXperts.Ssh")         ' Create an Ssh instance
objSsh.Host          = "192.168.1.10"                           ' Hostname or IP address of remote UNIX/LINUX machine
objSsh.UserName      = "root"                                   ' Login as 'root'
objSsh.Password      = "topsecret"                              ' Use a password to login
objSsh.Command       = "/bin/ls"                                ' Command to execute
objSsh.ScriptTimeOut = 5000                                     ' Time-out (in milliseconds)
objSsh.Run                                                      ' Execute the command now
WScript.Echo "Run: result = " & objSsh.LastError 
If objSsh.LastError <> 0 Then
  WScript.Quit
End If

' YES, command has completed
WScript.Echo "StdErr: " & objSsh.StdErr                         ' Print Standard Output
WScript.Echo "StdOut: " & objSsh.StdOut                         ' Print Standard Error

WScript.Echo "Ready."
RSH sample (run a command on a remote LINUX/UNIX host in an unsecure way)
Set objRsh           = CreateObject("ActiveXperts.Rsh")         ' Create new Rsh instance
objRsh.Clear
objRsh.Host          = "192.168.1.10"                           ' Host/IP of the remote UNIX/LINUX machine
objRsh.Command       = "/bin/ls"                                ' Command to execute on the remote machine
objRsh.ScriptTimeOut = 5000                                     ' Time-out (in milliseconds)
objRsh.Run                                                      ' Run the command now
If objRsh.LastError <> 0 Then
 WScript.Echo "Error " & objRsh.LastError
WScript.Quit
End If

' YES, command has completed
WScript.Echo "StdErr: " & objRsh.StdErr                         ' Display stdout
WScript.Echo "StdOut: " & objRsh.StdOut                         ' Display stderr
Client/Server TCP application (1 client script, 1 server script)
' C L I E N T . V B S

Set objTcp     = CreateObject("ActiveXperts.Tcp")               ' Create new Tcp instance
Set objConstants  = CreateObject( "ActiveXperts.ASConstants" )  ' Create a new Constants instance 
objTcp.Protocol= objConstants.asSOCKET_PROTOCOL_RAW             ' Plain TCP/IP communications

objTcp.Connect "127.0.0.1", 1500                                ' Connect to port 1500 on remote server
WScript.Echo "Connect: result = " & objTcp.LastError
If objTcp.LastError <> 0	 Then
  WScript.Echo "Error #" & objTcp.LastError & ": " & objTcp.GetErrorDescription( objTcp.LastError )
  WScript.Quit
End If

objTcp.SendString "This is a message"                           ' Send ASCII data
WScript.Echo "SendString, result: " & objTcp.LastError
objTcp.Sleep 1000                                               ' Hold script for 1000 msec

objTcp.SendString "Quit", False                                 ' Send ASCII data
objTcp.Disconnect                                               ' And finally, disconnect


' S E R V E R . V B S
Set objTcp     = CreateObject("ActiveXperts.Tcp")               ' Create new Tcp instance
Set objConstants  = CreateObject( "ActiveXperts.ASConstants" )  ' Create a new Constants instance 
objTcp.Protocol= objConstants.asSOCKET_PROTOCOL_RAW             ' Plain TCP/IP communications

objTcp.StartListening 1500                                      ' Listen on port 1500
If objTcp.LastError <> 0 Then
  WScript.Echo "Error " & objTcp.LastError & ": " & objTcp.GetErrorDescription( objTcp.LastError )
  WScript.Quit
End If

Do while objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_LISTENING
  objTcp.Sleep 1000                                             ' Wait for incoming connection...
Loop

If objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_LISTENING Then
  str = ""                                                      ' Connection established
  Do While objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_LISTENING and str <> "Quit"

     If objTcp.HasData Then
        str = objTcp.ReceiveString
        WScript.Echo "ReceiveString: " & str
     End If
     objTcp.Sleep 100
  Loop

  objTcp.Disconnect                                             ' And finally, disconnect
End If
Client/Server UDP application (1 client script, 1 server script)
' C L I E N T . V B S

' Create a socket instance
Set objUdp       = CreateObject ( "ActiveXperts.Udp" )
Set objConstants = CreateObject ( "ActiveXperts.ASConstants" )

' Write some information to console
WScript.Echo "ActiveSocket " & objUdp.Version & " demo."
WScript.Echo "Expiration date: " & objUdp.ExpirationDate & vbCrLf

' Open socket to send to port 1500 on remote server
objUdp.Open "localhost", 1500, False
WScript.Echo "Open, result: " & objUdp.LastError & _
            " (" & objUdp.GetErrorDescription( objUdp.LastError ) & ")"
If( objUdp.LastError <> 0 ) Then
  WScript.Echo "Ready."
  WScript.Quit
End If

str = "This is just a message"
objUdp.SendString str                                           ' Send message
WScript.Echo "SendString '" & str & "': result = " & objUdp.LastError
objUdp.Sleep 100

str = "And this is another message"
objUdp.SendString str                                           ' Send another message
WScript.Echo "SendString '" & str & "': result = " & objUdp.LastError
objUdp.Sleep 100

str = "Quit"
objUdp.SendString str                                           ' Send last message
WScript.Echo "SendString '" & str & "': result = " & objUdp.LastError
objUdp.Sleep 100

objUdp.Close                                                    ' And finally, close the socket


' S E R V E R . V B S
' Create a socket instance
Set objUdp       = CreateObject ( "ActiveXperts.Udp" )
Set objConstants = CreateObject ( "ActiveXperts.ASConstants" )

' Write some information to console
WScript.Echo "ActiveSocket " & objUdp.Version & " demo."
WScript.Echo "Expiration date: " & objUdp.ExpirationDate & vbCrLf

' Open socket to receive UDP datagrams on port 1500 on this machine
objUdp.Open "localhost", 1500, True
WScript.Echo "Open, result: " & objUdp.LastError & _
            " (" & objUdp.GetErrorDescription( objUdp.LastError ) & ")"
If( objUdp.LastError <> 0 ) Then
  WScript.Echo "Ready."
  WScript.Quit
End If

Do While str <> "Quit"
  str = objUdp.ReceiveString                                    ' Receive message	
  If( objUdp.LastError = 0 And str <> "" ) Then
      WScript.Echo "ReceiveString: " & str
  End If	
  objUdp.Sleep ( 100 )
Loop

objUdp.Close
NTP sample (query a remote time server)
Set objNtp = CreateObject("ActiveXperts.Ntp")                   ' Create new Ntp instance
objNtp.GetTime "fartein.ifi.uio.no"                             ' Query the time server
If( objNtp.LastError <> 0 ) Then
 WScript.Echo "Unable to retrieve time, error: " & objNtp.LastError
 WScript.Quit
End If

WScript.Echo "Time on timeserver: " & objNtp.Year & _           ' Display date and time
   "/" & objNtp.Month &  "/" & objNtp.Day & _                   ' Display date and time
   " " & objNtp.Hour & ":" &  objNtp.Minute & _                 ' Display date and time
   ":" &   objNtp.Second
WScript.Echo "DifferenceTime Server / Local PC: " & _           ' Display time offset
   objNtp.LocalOffsetSeconds & " seconds"                       ' Display time offset
End If
SNMP Walker (walk through the SNMP MIB database)
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new Snmp instance
objSnmpManager.Initialize                                       ' Initialize Snmp
objSnmpManager.Open "192.168.1.100", "public"
If( objSnmpManager.LastError = 0 )
 Set objSnmpObject = objSnmpManager.Get( "system.sysName.0" )   ' Get SnmpObject object
 While( objSnmpManager.LastError = 0 )
   WScript.Echo "Type:  " & objSnmpObject.Type
   WScript.Echo "Value: " & objSnmpObject.Value

   Set objSnmpObject = objSnmpManager.GetNext()                 ' Get next SnmpObject object
 End If
 objSnmpManager.Close
End If
objSnmpManager.Shutdown                                         ' Uninitialize Snmp
SNMP Traps (1 sender script, 1 receiver script)
' T R A P R E C E I V E R . V B S

Set objTrapManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
objTrapManager.Initialize                                       ' Initialize SNMP
If( objTrapManager.LastError <> 0 ) Then
  WScript.Quit
End If

objTrapManager.StartListening "public"                          ' Start listening now
If( objTrapManager.LastError <> 0 ) Then
  objTrapManager.Shutdown                                       ' Uninitialize SNMP
  WScript.Quit
End If

Set objSnmpTrap = objTrapManager.GetFirstTrap                   ' Get trap

While( objTrapManager.LastError = 0 )
  WScript.Echo "Trap from      : " & objSnmpTrap.Host
  WScript.Echo "  Community   : " & objSnmpTrap.Community

  Set objSnmpObject = objSnmpTrap.GetFirstObject      
  While( objSnmpTrap.LastError = 0 )                            ' iterate over all variables in the trap
    
    WScript.Echo "OID : " & objSnmpObject.OID
    WScript.Echo "Value:" & objSnmpObject.Value   
    WScript.Echo "Type:"  & GetTypeString( objSnmpObject.Type )
  
    Set objSnmpObject = objSnmpTrap.GetNextObject
  WEnd

  Set objSnmpTrap = objTrapManager.GetNextTrap                  ' Get next trap
WEnd  

objTrapManager.StopListening                                    ' Stop listening for incoming traps
objTrapManager.Shutdown                                         ' Uninitialize SNMP


' T R A P S E N D E R . V B S
Set objSnmpTrapManager = CreateObject("ActiveXperts.SnmpTrapManager") ' Create a new SnmpTrapManager instance
Set objSnmpTrap        = CreateObject( "ActiveXperts.SnmpTrap" ) ' Create a new SnmpTrap instance
Set objSnmpObject      = CreateObject( "ActiveXperts.SnmpObject" ) ' Create a new SnmpObject instance
Set objConstants       = CreateObject( "ActiveXperts.ASConstants" ) ' Create a new Constants instance 
objSnmpTrapManager.Initialize                                   ' Initialize SNMP
If( objSnmpTrapManager.LastError <> 0 ) Then
  WScript.Quit
End If

' Set trap properties
objSnmpTrap.Clear()
objSnmpTrap.Host	  = "server06"
objSnmpTrap.Community = "public"

' Add a variable to the trap
objSnmpObject.Clear()                                           ' Clear trap object
objSnmpObject.OID   = ".1.3.6.1.2.1.1.5.0"                      ' Set trap properties
objSnmpObject.Type  = objConstants.asSNMP_TYPE_IPADDRESS        ' Set trap properties
objSnmpObject.Value = "10.0.0.1"                                ' Set trap properties 
objSnmpTrap.AddObject objSnmpObject                             ' Add the trap to the queue

' Add another variable to the trap
objSnmpObject.Clear()                                           ' Clear trap object
objSnmpObject.OID   = ".1.3.6.1.2.1.1.5.1"                      ' Set trap properties
objSnmpObject.Type  = objConstants.asSNMP_TYPE_OCTETSTRING      ' Set trap properties
objSnmpObject.Value = "One two three"                           ' Set trap properties 
objSnmpTrap.AddObject objSnmpObject                             ' Add the trap to the queue

objSnmpTrapManager.Send objSnmpTrap                             ' Send trap
WScript.Echo "Send, result: " & objSnmpTrapManager.LastError    ' Display the result

objSnmpTrapManager.Shutdown                                     ' Uninitialize SNMP
Telnet sample (connect to a web site through a telnet session)
Set objTcp = CreateObject("ActiveXperts.Tcp")                   ' Create new Tcp instance
Set objConstants = CreateObject( "ActiveXperts.ASConstants" )   ' Create a new Constants instance 
objTcp.Protocol = objConstants.asSOCKET_PROTOCOL_TELNET         ' Telnet communications

objTcp.Connect "www.activexperts.com", 80                       ' Connect to web site on port 80
Wscript.Echo "Connect,, result: " & objTcp.LastError
If objTcp.LastError <> 0 Then
  WScript.Quit
End If

If objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_CONNECTED Then

 strReceived = ""                                               ' Connection established
 objTcp.Sleep 1000

 objTcp.SendString "GET /activsocket/demopage/ HTTP/1.1"        ' Send string
 objTcp.SendString "Host: www.activexperts.com" & vbCrlf        ' Send string
 objTcp.Sleep 1000

 If objTcp.HasData Then
   strReceived = objTcp.ReceiveString                           ' Receive data
   WScript.Echo "RECV: " & strReceived
 End If
  
 objTcp.Sleep 1000 
 objTcp.Disconnect                                              ' Disconnect from server
End If
IP to Country sample (maps an IP address to a country
Set objIPC = CreateObject( "ActiveXperts.IPtoCountry" )         ' Create a new IPtoCountry instance
objIPC.Host = "www.activexperts.com"                            ' Host name (or IP address) that you want to resolve
objIPC.Query()                                                  ' Host name (or IP address) that you want to resolve
WScript.Echo "Query, result: " & objIPC.LastError               ' Result of Query; 0 means: success
If objIPC.LastError = 0 Then
  WScript.Echo "Host " & strHost & " is located in " & objIPC.CountryName
End If
MSN sample (send an MSN message to a remote MSN recipient)
Set objMsn = CreateObject( "ActiveXperts.Msn" )                 ' Create Msn object

objMsn.Server       = "messenger2.hotmail.com"                  ' Use messenger2.hotmail.com
objMsn.MsnAccount   = "mymeself@activexperts.com"               ' Set MSN Account
objMsn.MsnPassword  = "topsecret"                               ' Set MSN Password

objMsn.Message      = "Hello World !!!!"                        ' Set MSN Message
objMsn.AddRecipient "mycollegue1@activexperts.com"              ' Add recipient(s)
objMsn.AddRecipient "mycollegue2@activexperts.com"               

objMsn.Send                                                     ' Send the message

WScript.Echo "Result : " & objMsn.LastError                     ' Display the result
Wake_On-LAN sample (Power-Up a remote computer)
Set objWOL = CreateObject( "ActiveXperts.WOL" )                 ' Create a new WOL instance
strMAC = "00-10-4B-BA-7A-51"
objWOL.WakeUp strMAC                                            ' Send magic packet to remote station identified by MAC
WScript.Echo "WakeUp, result = " & objWOL.LastError             ' Display the result

4.2. Visual Basic .NET

Make sure the ActiveSocket Toolkit is installed on your system. For details about installation, click here.

Add a reference to the object using the Visual Basic Solution Explorer:

You can use different ActiveSocket objects in one Visual Basic .NET application. The following code shows how to declare and create all ActiveSocket objects:

Imports ASocket

Dim objConstants As SocketConstants              ' Declaration
objConstants = New SocketConstants()             ' Creation

Dim objIcmp As Icmp                              ' Declaration
objIcmp = New Icmp()                             ' Creation

Dim objTcp As Tcp                                ' Declaration
objTcp = New Tcp()                               ' Creation

Dim objUdp As Udp                                ' Declaration
objUdp = New Udp()                               ' Creation

Dim objHttp As Http                              ' Declaration
objHttp = New Http()                             ' Creation

Dim objFtpServer As FtpServer                    ' Declaration
objFtpServer = New FtpServer()                   ' Creation
Dim objFtpFile As FtpFile                        ' Declaration
objFtpFile = New FtpFile()                       ' Creation

Dim objTftpServer As TftpServer                  ' Declaration
objTftpServer = New TftpServer()                 ' Creation

Dim objDnsServer As DnsServer                    ' Declaration
objDnsServer = New DnsServer()                   ' Creation
Dim objDnsRecord As DnsRecord                    ' Declaration
objDnsRecord = New DnsRecord()                   ' Creation

Dim objNtp As Ntp                                ' Declaration
objNtp = New Ntp()                               ' Creation

Dim objSsh As Ssh                                ' Declaration
objSsh = New Ssh()                               ' Creation

Dim objRsh As Rsh                                ' Declaration
objRsh = New Rsh()                               ' Creation

Dim objSnmpManager As SnmpManager                ' Declaration
objSnmpManager = New SnmpManager()               ' Creation
Dim objSnmpObject As SnmpObject                  ' Declaration
objSnmpObject = New SnmpObject()                 ' Creation

Dim objSnmpTrapManager As SnmpTrapManager        ' Declaration
objSnmpTrapManager = New SnmpTrapManager()       ' Creation
Dim objSnmpTrap As SnmpTrap                      ' Declaration
objSnmpTrap = New SnmpTrap()                     ' Creation

Dim objSnmpMib As SnmpMibBrowser                 ' Declaration
objSnmpMib = New SnmpMibBrowser()                ' Creation

Dim objIPC As IPtoCountry                        ' Declaration
objIPC = New IPtoCountry()                       ' Creation

Dim objMsn As Msn                                ' Declaration
objMsn = New Msn()                               ' Creation

Dim objWOL As WOL                                ' Declaration
objWOL = New WOL()                               ' Creation

After these declarations and creation of the object(s), you can use the objects inside your Visual Basic .NET project.

4.3. Visual C# .NET

Make sure the ActiveSocket Toolkit is installed on your system. For details about installation, click here.

Add a reference to the object using the Visual C# Solution Explorer:

You can use different ActiveSocket objects in one Visual C# .NET application. The following code shows how to declare and create the ActiveSocket objects:

using ASOCKETLib

SocketConstants objConstants;                    // Declaration
objConstants = new SocketConstants();            // Creation

Tcp objTcp;                                      // Declaration
objTcp = new Tcp();                              // Creation

Udp objUdp;                                      // Declaration
objUdp = new Udp();                              // Creation

Icmp objIcmp;                                    // Declaration
objIcmp = new Icmp();                            // Creation

Http objHttp;                                    // Declaration
objHttp = new Http();                            // Creation

FtpServer objFtpServer;                          // Declaration
objFtpServer = new FtpServer();                  // Creation
FtpFile objFtpFile;                              // Declaration
objFtpFile = new FtpFile();                      // Creation

TftpServer objTftpServer;                        // Declaration
objTftpServer = new TftpServer();                // Creation

DnsServer objDnsServer;                          // Declaration
objDnsServer = new DnsServer();                  // Creation
DnsRecord objDnsRecord;                          // Declaration
objDnsRecord = new DnsRecord();                  // Creation

Ntp objNtp;                                      // Declaration
objNtp = new Ntp();                              // Creation

Ssh objSsh                                       // Declaration
objSsh = new Ssh();                              // Creation

Rsh objRsh                                       // Declaration
objRsh = new Rsh();                              // Creation

SnmpManager objSnmpManager;                      // Declaration
objSnmpManager = new SnmpManager();              // Creation
SnmpObject objSnmObject;                         // Declaration
objSnmpObject = new SnmpObject();                // Creation

SnmpTrapManager objSnmpTrapManager;              // Declaration
objSnmpTrapManager = new SnmpTrapManager();      // Creation
SnmpTrap objSnmpTrap;                            // Declaration
objSnmpTrap = new SnmpTrap();                    // Creation

SnmpMibBrowser objSnmpMib;                       // Declaration
objSnmpMib = new SnmpMibBrowser();               // Creation

IPtoCountry objIPC;                              // Declaration
objIPC = new IPtoCountry();                      // Creation

Msn objMsn;                                      // Declaration
objMsn = new Msn();                              // Creation

WOL objWOL;                                      // Declaration
objWOL = new WOL();                              // Creation

After these declarations and creation of the object(s), you can use the objects inside your Visual C# .NET project.

4.4. Visual Basic

ActiveSocket can be used in Visual Basic 5.x or higher. In Visual Basic, go to the 'Project/References...' menu item and check the box next to ActiveSocket Type Library. Now, you can declare and create ActiveSocket objects.

Create new ActiveSocket objects using the 'CreateObject' function:

Dim objConstants As ASOCKETLib.SocketConstants                  ' Declaration
Set objConstants = CreateObject( "ActiveXperts.ASConstants" )   ' Creation

Dim objIcmp As ASOCKETLib.Icmp                                  ' Declaration
Set objIcmp = CreateObject( "ActiveXperts.Icmp" )               ' Creation

Dim objTcp As ASOCKETLib.Tcp                                    ' Declaration
Set objTcp = CreateObject( "ActiveXperts.Tcp" )                 ' Creation

Dim objUdp As ASOCKETLib.Udp                                    ' Declaration
Set objUdp = CreateObject( "ActiveXperts.Udp" )                 ' Creation

Dim objHttp As ASOCKETLib.Http                                  ' Declaration
Set objHttp = CreateObject( "ActiveXperts.Http" )               ' Creation

Dim objFtpServer As ASOCKETLib.FtpServer                        ' Declaration
Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" )     ' Creation
Dim objFtpFile  As ASOCKETLib.FtpFile                           ' Declaration
Set objFtpFile = CreateObject( "ActiveXperts.FtpFile")          ' Creation

Dim objTftpServer As ASOCKETLib.TftpServer                      ' Declaration
Set objTftpServer = CreateObject( "ActiveXperts.TftpServer" )   ' Creation

Dim objDnsServer As ASOCKETLib.DnsServer                        ' Declaration
Set objDnsServer = CreateObject( "ActiveXperts.DnsServer" )     ' Creation
Dim objDnsRecord  As ASOCKETLib.DnsRecord                       ' Declaration
Set objDnsRecord = CreateObject( "ActiveXperts.DnsRecord")      ' Creation

Dim objNtp As ASOCKETLib.Ntp                                    ' Declaration
Set objNtp = CreateObject( "ActiveXperts.Ntp" )                 ' Creation

Dim objSsh As ASOCKETLib.Ssh                                    ' Declaration
Set objSsh = CreateObject( "ActiveXperts.Ssh" )                 ' Creation

Dim objRsh As ASOCKETLib.Rsh                                    ' Declaration
Set objRsh = CreateObject( "ActiveXperts.Rsh" )                 ' Creation

Dim objSnmpManager  As ASOCKETLib.SnmpManager                   ' Declaration
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Creation
Dim objSnmpObject As ASOCKETLib.SnmpObject                      ' Declaration
Set objSnmpObject = CreateObject( "ActiveXperts.SnmpObject")    ' Creation

Dim objSnmpTrapManager  As ASOCKETLib.SnmpTrapManager           ' Declaration
Set objSnmpTrapManager = CreateObject( "ActiveXperts.SnmpTrapManager" )  ' Creation
Dim objSnmpTrap As ASOCKETLib.SnmpTrap                          ' Declaration
Set objSnmpTrap = CreateObject( "ActiveXperts.SnmpTrap" )       ' Creation

Dim objSnmpMib As ASOCKETLib.SnmpMibBrowser                     ' Declaration
Set objSnmpMib = CreateObject( "ActiveXperts.SnmpMibBrowser" )  ' Creation

Dim objIPC  As ASOCKETLib.IPtoCountry                           ' Declaration
Set objIPC = CreateObject( "ActiveXperts.IPtoCountry")          ' Creation

Dim objMsn  As ASOCKETLib.Msn                                   ' Declaration
Set objMsn = CreateObject( "ActiveXperts.Msn")                  ' Creation

Dim objWOL  As ASOCKETLib.WOL                                   ' Declaration
Set objWOL = CreateObject( "ActiveXperts.WOL")                  ' Creation

After these declarations and creation of the object(s), you can use the objects inside your Visual Basic 5.x/6.x project.

4.5. How to use ActiveSocket in Visual C++

ActiveSocket can be used in Visual C++ projects. Include the *.h and *.c file provided by ActiveXperts to bind your code to the ActiveSocket component. These files are located in the Include directory of the Visual C++ samples directory. These are the files:

Declare and create new ActiveSocket objects like this:

ISocketConstants *pConstants;                                    
CoCreateInstance(CLSID_SocketConstants, NULL, CLSCTX_INPROC_SERVER, IID_ISocketConstants, (void**) &pConstants );

IIcmp *pIcmp;                                                          
CoCreateInstance(CLSID_Icmp, NULL, CLSCTX_INPROC_SERVER, IID_IIcmp, (void**) &pIcmp );

ITcp *pTcp;                          
CoCreateInstance(CLSID_Tcp, NULL, CLSCTX_INPROC_SERVER, IID_ITcp, (void**) &pTcp ); 

IUdp *pUdp;                         
CoCreateInstance(CLSID_Udp, NULL, CLSCTX_INPROC_SERVER, IID_IUdp, (void**) &pUdp );

IHttp *pHttp;                     
CoCreateInstance(CLSID_Http, NULL, CLSCTX_INPROC_SERVER, IID_IHttp, (void**) &pHttp );            

IFtpServer *pFtpServer;           
CoCreateInstance(CLSID_FtpServer, NULL, CLSCTX_INPROC_SERVER, IID_IFtpServer, (void**) &pFtpServer ) 
IFtpFile *pFtpFile;               
CoCreateInstance(CLSID_FtpFile, NULL, CLSCTX_INPROC_SERVER, IID_IFtpFile, (void**) &pFtpFile )  

ITftpServer *pTftpServer;         
CoCreateInstance(CLSID_TftpServer, NULL, CLSCTX_INPROC_SERVER, IID_ITftpServer, (void**) &pTftpServer )

IDnsServer *pDnsServer;              
CoCreateInstance(CLSID_DnsServer, NULL, CLSCTX_INPROC_SERVER, IID_IDnsServer, (void**) &pDnsServer ) 
IDnsRecord *pDnsRecord;             
CoCreateInstance(CLSID_DnsRecord, NULL, CLSCTX_INPROC_SERVER, IID_IDnsRecord, (void**) &pDnsRecord )

INtp *pNtp;                       
CoCreateInstance(CLSID_Ntp, NULL, CLSCTX_INPROC_SERVER, IID_INtp, (void**) &pNtp )

ISsh *pSsh;                       
CoCreateInstance(CLSID_Ssh, NULL, CLSCTX_INPROC_SERVER, IID_ISsh, (void**) &pSsh )

IRSh *pRsh;                         
CoCreateInstance(CLSID_RSh, NULL, CLSCTX_INPROC_SERVER, IID_IRSh, (void**) &pRSh ) 

ISnmpManager *pSnmpManager;     
CoCreateInstance(CLSID_SnmpManager, NULL, CLSCTX_INPROC_SERVER, IID_ISnmpManager, (void**) &pSnmpManager )
ISnmpObject *pSnmpObject;          
CoCreateInstance(CLSID_SnmpObject, NULL, CLSCTX_INPROC_SERVER, IID_ISnmpObject, (void**) &pSnmpObject ) 

ISnmpTrapManager *pSnmpTrapManager;  
CoCreateInstance(CLSID_SnmpTrapManager, NULL, CLSCTX_INPROC_SERVER, IID_ISnmpTrapManager, (void**) &pSnmpTrapManager )
ISnmpTrap *pSnmpTrap;              
CoCreateInstance(CLSID_SnmpTrap, NULL, CLSCTX_INPROC_SERVER, IID_ISnmpTrap, (void**) &pSnmpTrap )    

ISnmpMibBrowser *pSnmpMib;        
CoCreateInstance(CLSID_SnmpMibBrowser, NULL, CLSCTX_INPROC_SERVER, IID_ISnmpMibBrowser, (void**) &pSnmpMib ) 

IIPtoCountry *pIPC;               
CoCreateInstance(CLSID_IPtoCountry, NULL, CLSCTX_INPROC_SERVER, IID_IIPtoCountry, (void**) &pIPC )  

IMsn *pMsn;               
CoCreateInstance(CLSID_Msn, NULL, CLSCTX_INPROC_SERVER, IID_IMsn, (void**) &pMsn )  

IWOL *pWol;                         
CoCreateInstance(CLSID_WOL, NULL, CLSCTX_INPROC_SERVER, IID_IWOL, (void**) &pWOL ) 

Visual C++ samples are installed as part of the product, but can also be found on our website.

4.6. How to use ActiveSocket in an ASP 2.x environment

<html>
<body>
Version:
<script language=vbscript runat=server>
  Set objTcp = CreateObject( "ActiveXperts.Tcp" )
  Response.Write objTcp.Version
</script>
</body>
</html>

4.7. How to use ActiveSocket in Delphi 7.x or higher

Make sure the ActiveSocket Toolkit is installed on your system. For details about installation, click here.

First, add a reference to the ActiveSocket objects:

Create the various ActiveSocket object instances like this:

objConst      : ISocketConstants;                                 { Declaration of the interface class  }
objConst      := TSocketConstants.Create(Form1).DefaultInterface; { Creation new instance of the object }

objTcp        : ITcp;                                             { Declaration of the interface class  }
objTcp        := TTcp.Create(Form1).DefaultInterface;             { Creation new instance of the object }

objUdp        : IUdp;                                             { Declaration of the interface class  }
objUdp        := TUdp.Create(Form1).DefaultInterface;             { Creation new instance of the object }

objIcmp       : IICmp;                                            { Declaration of the interface class  }
objIcmp       := TIcmp.Create(Form1).DefaultInterface;            { Creation new instance of the object }       

objHttp       : IHttp;                                            { Declaration of the interface class  }
objHttp       := THttp.Create(Form1).DefaultInterface;            { Creation new instance of the object }       

objFtpServer  : IFtpServer;                                       { Declaration of the interface class  }
objFtpServer  := TFtpServer.Create(Form1).DefaultInterface;       { Creation new instance of the object }       
objFtpFile    : IFtpFile;                                         { Declaration of the interface class  }
objFtpFile    := TFtpFile.Create(Form1).DefaultInterface;         { Creation new instance of the object }       

objTftpServer : ITftpServer;                                      { Declaration of the interface class  }
objTftpServer := TFtpServer.Create(Form1).DefaultInterface;       { Creation new instance of the object }       

objDnsServer  : IDnsServer;                                       { Declaration of the interface class  }
objDnsServer  := TDnsServer.Create(Form1).DefaultInterface;       { Creation new instance of the object }       
objDnsRecord  : IDnsRecord;                                       { Declaration of the interface class  }
objDnsRecord  := TDnsRecord.Create(Form1).DefaultInterface;       { Creation new instance of the object }       

objNtp        : INtp;                                             { Declaration of the interface class  }
objNtp        := TNtp.Create(Form1).DefaultInterface;             { Creation new instance of the object }       

objSsh        : ISsh;                                             { Declaration of the interface class  }
objSsh        := TSsh.Create(Form1).DefaultInterface;             { Creation new instance of the object }       

objRsh        : IRSh;                                             { Declaration of the interface class  }
objRsh        := TRSh.Create(Form1).DefaultInterface;             { Creation new instance of the object }       

objManager    : ISnmpManager;                                     { Declaration of the interface class  }
objManager    := TSnmpManager.Create(Form1).DefaultInterface;     { Creation new instance of the object }       
objSnmpObject : ISnmpObject;                                      { Declaration of the interface class  }
objSnmpObject := TSnmpObject.Create(Form1).DefaultInterface;      { Creation new instance of the object }       

objManager    : ISnmpTrapManager;                                 { Declaration of the interface class  }
objManager    := TSnmpTrapManager.Create(Form1).DefaultInterface; { Creation new instance of the object }       
objData       : ISnmpTrapData;                                    { Declaration of the interface class  }
objData       := TSnmpTrapData.Create(Form1).DefaultInterface;    { Creation new instance of the object }       

objSnmpMib    : ISnmpMibBrowser;                                  { Declaration of the interface class  }
objSnmpMib    := TSnmpMibBrowser.Create(Form1).DefaultInterface;  { Creation new instance of the object }       

objIPC        : IIPtoCountry;                                     { Declaration of the interface class  }
objIPC        := TIPtoCountry.Create(Form1).DefaultInterface;     { Creation new instance of the object }       

objMsn        : IMsn;                                             { Declaration of the interface class  }
objMsn        := TMsn.Create(Form1).DefaultInterface;             { Creation new instance of the object }       

objWOL        : IWOL;                                             { Declaration of the interface class  }
objWOL        := TWOL.Create(Form1).DefaultInterface;             { Creation new instance of the object }       

After these declarations and creation of the object(s), you can use the objects in your Delphi projects.

5. ICMP Object

5.1. ICMP Object - Introduction

ICMP/Ping is one of the most commonly used utilities on the Internet by people and programs, with untold millions of pings flashing every second back and forth between computers. The original PING utility stood for "Packet Internet Groper", and was a package of diagnostic utilities used by DARPA personnel to test the performance of the ARPANET. Almost every operating system includes a Ping program. It has become one of the most versatile and widely used diagnostic tools on the Internet.

ICMP/Ping sends a small packet of information containing an ICMP ECHO_REQUEST to a specified computer, which then sends an ECHO_REPLY packet in return.

You can use Ping to perform several useful network diagnostics, such as the following:

The ActiveSocket Icmp object enables you to add Icmp/Ping functionality to your program.
Here is a small example (in VBScript) to show how to use the Icmp object:

Set objIcmp        = CreateObject("ActiveXperts.Icmp")          ' Create Icmp object
objIcmp.Ping "www.activexperts.com", 2000                       ' Ping host; timeout 2000 ms
If( objIcmp.LastError = 0 ) Then
 WScript.Echo "Success, duration: " & objIcmp.LastDuration & "ms"
Else
 WScript.Echo "Error " & objIcmp.LastError & ": " & objIcmp.GetErrorDescription( objIcmp.LastError )
End If
WScript.Echo "Ready."

5.2. Icmp object - Properties and Functions Overview

Property Type In/Out Mand/Opt Description
Version String Out n/a Version number of ActiveSocket
Build String Out n/a Display build information of ActiveSocket
ExpirationDate String Out n/a Expiration date of ActiveSocket
LogFile String In/Out n/a Log file; use it for troubleshooting purposes
Ttl Number In/Out No Maximum Time To Live in next Ping call
BufferSize Number In/Out No Send buffer size
LastError Number Out n/a Result of the last called function
LastDuration Number Out n/a Reply time of the last Ping call
LastTtl Number Out n/a TTL of last Ping call

Function Description
Clear Clear all properties
Ping Ping the specified host
GetErrorDescription Get the description of the given error
Sleep Suspends the execution of the object for at least the specified interval

5.3. Icmp Object - Properties

Icmp.Version property

Type:

String

Description:

Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objIcmp = CreateObject( "ActiveXperts.Icmp" )          ' Create Icmp object
WScript.Echo  "Version: " & objIcmp.Version

Icmp.Build property

Type:

String

Description:

Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objIcmp = CreateObject( "ActiveXperts.Icmp" )          ' Create Icmp object
WScript.Echo  "Build: " & objIcmp.Build

Icmp.ExpirationDate property

Type:

String

Description:

Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.

Example:

Set objIcmp = CreateObject( "ActiveXperts.Icmp" )          ' Create Icmp object
WScript.Echo "ExpirationDate: " & objIcmp.ExpirationDate

Icmp.LogFile property

Type:

String

Description:

For troubleshooting purposes, you can specify a log file to trace all operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all operations will be written to this log file.

Example:

Set objIcmp = CreateObject( "ActiveXperts.Icmp" )          ' Create Icmp object
objIcmp.LogFile = "c:\file.log

Icmp.Ttl property

Type:

Number

Description:

Time To Live to be used in the next Ping call. Value must be between 1 and 255. Default value is 255.

Example:

Set objIcmp  = CreateObject( "ActiveXperts.Icmp" )
objIcmp.Ttl  = 100                                         ' Use a different Time To Live than the default 255 value
objIcmp.Ping "www.monitortools.com", 2000                  ' Ping monitortools.com, timeout after 2000 msec
If( objIcmp.LastError = 0 ) Then
  WScript.Echo "TTL: " & objIcmp.LastTtl
End If

Icmp.BufferSize property

Type:

Number

Description:

Buffer size (in bytes) to be used in the next Ping call. Value must be between 0 and 8192. Default value is 32 (bytes).

Example:

Set objIcmp         = CreateObject( "ActiveXperts.Icmp" )  ' Create Icmp object
objIcmp.BufferSize  = 64                                   ' Use a different buffer size than the default (32 bytes)
objIcmp.Ping "www.monitortools.com", 2000                  ' Ping monitortools.com, timeout after 2000 msec

Icmp.LastError property

Type:

Number

Description:

The result of a previous called function. Use it to check the result of your last function call. A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.

Example:

Set objIcmp = CreateObject( "ActiveXperts.Icmp" )          ' Create Icmp object
objIcmp.Ping "server.mydomain.com", 2000
WScript.Echo "LastError: " & objIcmp.LastError

Icmp.LastDuration property

Type:

Number

Description:

The duration of the last Ping call. The property is read-only; you cannot assign a value to it.

Example:

Set objIcmp = CreateObject( "ActiveXperts.Icmp" )          ' Create Icmp object
objIcmp.Ping "www.activexperts.com", 2000
WScript.Echo "Duration of ICMP/Ping operation: " & objIcmp.LastDuration

Icmp.LastTtl property

Type:

Number

Description:

The Time To Live value of the last Ping call. The property is read-only; you cannot assign a value to it.
The maximum Time To Live value is indicated by the Ttl property. The default maximum Time To Live value is 255, but you can assign any value between 1 and 255 to it.

Example:

Set objIcmp = CreateObject( "ActiveXperts.Icmp" )          ' Create Icmp object
objIcmp.Ping "www.monitortools.com", 2000
If( objIcmp.LastError = 0 ) Then
  WScript.Echo "TTL: " & objIcmp.LastTtl
End If

5.4. Icmp Object - Functions

Icmp.Clear function

Description:

Reset all properties to their initial values. Use this function when you make consecutive calls to the Ping function.

Parameters:

Return value:

Always 0.

Example:

Set objIcmp  = CreateObject( "ActiveXperts.Icmp" )         ' Create Icmp object
objIcmp.Ping "192.168.1.1", 2000
objIcmp.Clear
objIcmp.Ping "192.168.1.2", 2000

Icmp.Ping function

Description:

Ping the specified host. The function requires one parameter: the host that you want to check.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objIcmp  = CreateObject( "ActiveXperts.Icmp" )         ' Create Icmp object
objIcmp.Ping "192.168.1.1", 2000
objIcmp.Clear
objIcmp.Ping "192.168.1.2", 2000

Icmp.GetErrorDescription function

Description:

GetErrorDescription provides the error description of a given error code.

Parameters:

Return value:

The error description that is associated with the given error code.

Example:

Set objIcmp  = CreateObject( "ActiveXperts.Icmp" )         ' Create Icmp object
objIcmp.Ping "www.thisdoesnotexist.com", 2000
WScript.Echo "LastError: " & objIcmp.LastError
WScript.Echo "Error description: " & objIcmp.GetErrorDescription( objIcmp.LastError )

Icmp.Sleep function

Description:

This function can be used in your script anywhere you want. Suspends the execution of the object for at least the specified interval.

Parameters:

Return value:

Always 0.

Example:

Set objIcmp        = CreateObject( "ActiveXperts.Icmp" )        ' Create Icmp object
...
objIcmp.Sleep 500

6. Tcp Object

6.1. Tcp Object - Introduction

The ActiveSocket Tcp object is based on the Transport Control protocol (TCP) protocol. Transport Control Protocol is a Transport Layer host-to-host protocol that provides reliable, connection-oriented service for IP traffic. TCP transports a stream of data in both directions between end stations. TCP does this by breaking the data into segments for transmission across a network running Internet Protocol.

You can use the ActiveSocket Tcp object basically for two purposes:

6.2. Tcp Object - Client Server Communications

To establish a connection between two machines, one must act as a server and one must act as a client.
The server process waits for a client to connect. It listens on a port for an incoming connection of a client.
The client doesn't listen at all; it simply connects to a port on the server.
After a connection is established, there's no difference between client and server anymore. They can both send and receive, and they can both disconnect the session.

In order to communicate, the server must first create a socket object, and then 'listen' on a specific TCP port to wait for an incoming connection:

Set objTcp       = CreateObject( "ActiveXperts.Tcp" )           ' Create Tcp object
Set objConstants = CreateObject( "ActiveXperts.ASConstants" )   ' Create constants object
objTcp.StartListening 1500                                      ' listen on port 1500 for incoming connection

Then, the server must wait until a connection is established, i.e. when the state of the connection changes from asSOCKET_CONNSTATE_LISTENING to asSOCKET_CONNSTATE_CONNECTED:

Do While objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_LISTENING
Loop
If objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_CONNECTED Then
  ' YES, connection established.
End If

Once the connection has been established, server and client can communicate with eachother. They can both send and receive. To receive information, use the ReceiveString function:

Do While objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_CONNECTED
  str = objTcp.ReceiveString
Loop

Each time you call a function, you can check the result by checking the LastError property. For instance:

Set objTcp       = CreateObject( "ActiveXperts.Tcp" )           ' Create Tcp object
Set objConstants = CreateObject( "ActiveXperts.ASConstants" )   ' Create constants object
objTcp.StartListening 1500                                      ' listen on port 1500 for incoming connection
If objTcp.LastError = 0 Then
   ' Yes, socket is listening on the specific port for an incoming connection
End If

On the client side, the client must connect to a server on a specific server-port:

Set objTcp       = CreateObject( "ActiveXperts.Tcp" )           ' Create Tcp object
Set objConstants = CreateObject( "ActiveXperts.ASConstants" )   ' Create constants object
objTcp.Connect "remoteserver", 1500                             ' connect on port 1500
If objTcp.LastError = 0 Then
  ' YES, connection established
End If

Now, client and server are peers. They can both send and receive. They can send in the following way:

objTcp.SendData "This is a message from client.vbs."            ' Send data

A process can disconnect the session anytime they want:

objTcp.Disconnect                                               ' Disconnect

6.3. Tcp object - Telnet communications

Use the ActiveSocket Tcp object to establish a telnet session to a server or device and read its contents or configuration, for instance:

The following sample (in VBScript) reads information from the www.activexperts.com/activsocket/demopage page:

Set objTcp      = CreateObject("ActiveXperts.Tcp")              ' Create Tcp object
Set objConstants= CreateObject( "ActiveXperts.ASConstants" )    ' Create constants object
objTcp.Protocol = objConstants.asSOCKET_PROTOCOL_TELNET         ' Telnet protocol
objTcp.Connect "www.activexperts.com", 80                       ' Connect on port 80 to remote server
WScript.Echo "Connect, result: " & objTcp.LastError
If objTcp.LastError <> 0 Then
  WScript.Quit
End If

If objTcp.ConnectionState = asSOCKET_CONNSTATE_CONNECTED Then.
  WScript.Echo "Connection established" & vbCrLf
  strReceived = ""
  nCounter = nCounter + 1
  objTcp.Sleep 1000

  objTcp.SendString "GET /activsocket/demopage/ HTTP/1.1"       ' Send data
  objTcp.SendString "Host: www.activexperts.com"                ' Send data	
  objTcp.SendString ""                                          ' Send data (only CRLF)

  objTcp.Sleep 1000

  If objTcp.HasData Then
    strReceived = objTcp.ReceiveString                          ' Receive data	
    WScript.Echo "RECV: " & strReceived
  End If
  objTcp.Sleep 1000
  objTcp.Disconnect                                             ' Disconnect
End If

6.4. Tcp object - Properties and Functions

Property Type In/Out Mand/Opt Description
Build String Out n/a Display build information of ActiveSocket
ExpirationDate String Out n/a Expiration date of ActiveSocket
Protocol Number In/Out O The protocol to be used
NewLine String In/Out O The character sequence that forms a newline
ConnectionState Number Out n/a The state of the connection
IOTimeout Number In/Out O Maximum time of read operations
RemoteAddress String Out n/a The IP address and port number of the remote machine
LastError Number Out n/a Result of the last called function
LogFile String In/Out O Log file; use it for troubleshooting purposes

Function Description
Connect Connect to a (remote) server
Disconnect Disconnect a connected session
SendString Send a string of ASCII data over the network
SendByte Send a single byte over the network
SendBytes Send raw data over the network
StartListening Start listening for an incoming connection on a specified port
StopListening Stop listening for an incoming connection
HasData Is there data available on the socket?
ReceiveString Receive incoming ASCII data on the socket
ReceiveBytes Receive incoming binary data on the socket
ReceiveByte Receive a single byte on the socket
Sleep Suspends the execution of the object for at least the specified interval
GetErrorDescription Get the description of the given error
Activate Activate the product

6.5. Tcp Object - Properties

Tcp.Version property

Type:

String

Description:

Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objTcp    = CreateObject( "ActiveXperts.Tcp" )              ' Create Tcp object
Response.Write "Version: " & objTcp.Version

Tcp.Build property

Type:

String

Description:

Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objTcp = CreateObject( "ActiveXperts.Tcp" )                 ' Create Tcp object
WScript.Echo  "Build: " & objTcp.Build

Tcp.ExpirationDate property

Type:

String

Description:

Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it. Once you have registered the product, the property holds the empty string ("") value.

Example:

Set objTcp    = CreateObject( "ActiveXperts.Tcp" )              ' Create Tcp object
Response.Write "ExpirationDate: " & objTcp.ExpirationDate

Tcp.Protocol property

Type:

Number

Description:

The protocol to be used. Can be either asSOCKET_PROTOCOL_RAW for TCP/IP without supplemental on top, or asSOCKET_PROTOCOL_TELNET. The property is read/write.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
objTcp.Protocol = objConstants.asSOCKET_PROTOCOL_TELNET         ' Use telnet protocol
objTcp.Connect "server.mydomain.com", 23
Response.Write "Connect, result: " & objTcp.LastError

Tcp.NewLine property

Type:

String

Description:

The character sequence that forms a newline. Default value: the CRLF (carriage return / linefeed) string. Most frequent used newline strings:

A newline is used internally by two functions:

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
...
objTcp.Connect "192.168.1.1", 8081                              ' Connect
If objTcp.LastError = 0 Then
  objTcp.NewLine  = vbCr                                        ' Use CR in the subsequent ReceiveString/SendString calls
                                                                ' transmitted by the WriteString function
  objTcp.SendString "Hello"
  If objTcp.LastError = 0 Then
    WScript.Echo "SendString was successful"
  Else
    WScript.Echo "SendString failed"
  End If
  objTcp.Disconnect
End If

Tcp.ConnectionState property

Type:

Number

Description:

The state of the connection. There are 3 valid Connection States. The property is read-only; you cannot assign a value to it.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
...
objTcp.StartListening 8081                                      ' Create Tcp object        
If objTcp.LastError <> 0 Then
   WScript.Quit
End If
...
Do While objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_LISTENING
  objTcp.Sleep 1000
Loop
If objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_CONNECTED Then
  ' YES, connection established.
End If

Tcp.IOTimeout property

Type:

Number

Description:

Maximum IO timeout for read operations (specified in milliseconds). Increase this value when incomplete data is received.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
...
objTcp.Connect "192.168.1.1", 8081                              ' Connect to 192.168.1.1 on port 8081
WScript.Echo "Connect, result: " & objTcp.LastError             ' Print the result
...
objTcp.IOTimeout = 1000                                         ' Set IO timeout to 1000ms
...
Wscript.Echo objTcp.ReadString

Tcp.RemoteAddress property

Type:

String

Description:

The IP address and port of the remote party that you are connected to.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
...
objTcp.Connect "192.168.1.1", 8081                              ' Connect to 192.168.1.1 on port 8081
WScript.Echo "Connect, result: " & objTcp.LastError             ' Print the result
If( objTcp.LastError = 0 And objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_CONNECTED ) Then
    WScript.Echo "Connecteed to remote party: " & objTcp.RemoteAddress  ' IP:Port of the remote party
End If

Tcp.LastError property

Type:

Number

Description:

The result of a previous called function. Use it to check the result of your last function call. A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.

Example:

Set objTcp     = CreateObject( "ActiveXperts.Tcp" )             ' Create Tcp object
objTcp.Connect "server.mydomain.com", 8081
Response.Write "Connect, result: " & objTcp.LastError

Tcp.LogFile property

Type:

String

Description:

For troubleshooting purposes, you can specify a log file to trace all operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all operations will be written to this log file.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
objTcp.LogFile     = "c:\file.log"
objTcp.Connect "192.168.1.1", 8081                              ' Connect to 192.168.1.1 on port 8081
WScript.Echo "Connect, result: " & objTcp.LastError             ' Print the result
...

6.6. Tcp Object - Functions

Tcp.Connect function

Description:

Make a connection to a (remote) server on a TCP port.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
...
objTcp.Connect "192.168.1.1", 8081                              ' Connect to 192.168.1.1 on port 8081
WScript.Echo "Connect, result: " & objTcp.LastError             ' Print the result

Example:

objTcp.Connect "myserver", 8081

Tcp.Disconnect function

Description:

Disconnect an active TCP connection.
The function doesn't require any parameters.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
...
objTcp.Connect "192.168.1.1", 8081                              ' Connect
If objTcp.LastError = 0 Then
  objTcp.SendData "Hello"
  objTcp.Disconnect                                             ' Disconnect
End If

Tcp.SendString function

Description:

This function sends a string of printable ASCII data to the (remote) server.
Telnet functions need a NewLine after the data string. ActiveSocket will automatically append the NewLine to the string.
Use the SendByte or SendBytes functions to send binary data or strings without NewLine sequence over the network.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
...
objTcp.Connect "192.168.1.1", 8081                              ' Connect
If objTcp.LastError = 0 Then
  objTcp.SendString "Hello"
  If objTcp.LastError = 0 Then
    WScript.Echo "SendString was successful"
  Else
    WScript.Echo "SendString failed"
  End If
  objTcp.Disconnect
End If

Tcp.SendByte function

Description:

This function sends a single byte over the network. To send multiple bytes at once, use the SendBytes function. SendByte is ideal to send binary data; for ASCII data, it's recommended to use the SendString function.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
...
objTcp.Connect "192.168.1.1", 8081
If objTcp.LastError = 0 Then
  objTcp.SendByte &H01                                          ' Send one byte
  objTcp.SendByte &H04                                          ' Send one byte
  objTcp.SendByte &H00                                          ' Send one byte
End If

Tcp.SendBytes function

Description:

This function sends the specified bytes over the network.
Use the 'SendBytes' function to send binary data. To send ASCII (displayable) data, use the SendString function.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
...
objTcp.Connect "192.168.1.1", 8081
If objTcp.LastError = 0 Then
  objTcp.SendBytes "Hello"                                      ' Send a stream of bytes
End If

Tcp.StartListening function

Description:

This function starts a new listening thread. If the functon succeeds, the ConnectionState will be set to asSOCKET_CONNSTATE_LISTENING.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
objTcp.StartListening 15000                                     ' Wait for 15 seconds for an incoming connection
If objTcp.LastError <> 0 Then
   WScript.Quit
End If
Do While objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_LISTENING
   objTcp.Sleep 1000                                            ' Still waiting for the incoming call
Loop
If objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_CONNECTED Then
   ' YES, connection established
   objTcp.Disconnect
End If

Tcp.StopListening function

Description:

This function stops a listening thread. If the function succeeds, the ConnectionState will change from asSOCKET_CONNSTATE_LISTENING to asSOCKET_CONNSTATE_DISCONNECTED. There are no parameters required.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
...
objTcp.StartListening 15000                                     ' Wait for 15 seconds for an incoming connection
If objTcp.LastError = 0 Then
  objTcp.StopListening                                          ' Connection established; disconnect now
End If

Tcp.HasData function

Description:

Check if there's incoming data available.

Parameters:

Return value:

True if there's data available; otherwise False.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
...
Do While objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_CONNECTED
  If objTcp.HasData Then                                        ' Data available ?
    str = objTcp.ReceiveString
    WScript.Echo "Received: " & str
    objTcp.Sleep 100
  End If
Loop

Tcp.ReceiveString function

Description:

Read ASCII data from socket until a NewLine is read from the device or a timeout has elapsed.
NOTE: Use the ReceiveBytes or ReceiveByte functions to receive binary data from the (remote) computer).

Parameters:

Return value:

Empty string if there's no incoming data available; otherwise, the ASCII string that was read from the socket. Check LastError property to see if the function was completed successfully.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
...
Do While objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_CONNECTED
  If objTcp.HasData Then
    str = objTcp.ReceiveString
    WScript.Echo "Received: " & str
    objTcp.Sleep 100
  End If
Loop

Tcp.ReceiveBytes function

Description:

Read binary data from socket (use the ReceiveString function to receive ASCII data from the network).
ReceiveBytes receives and returns all the binary data from the network.

Parameters:

Return value:

The received datastring. Check LastError property to see if the function was completed successfully.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
...
If objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_CONNECTED Then
  If objTcp.HasData Then
    WScript.Echo objTcp.ReceiveBytes                            ' Receive stream of bytes
  End If
End If

Tcp.ReceiveByte function

Description:

Receive a single byte of binary data from the socket. Use the ReceiveBytes function to receive all binary data from the (remote) computer.

Parameters:

Return value:

The byte received. Check LastError property to see if the function was completed successfully.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
...
If objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_CONNECTED Then
  While objTcp.HasData 
    WScript.Echo "Received Byte: " & objTcp.ReceiveByte 
  WEnd
End If

Tcp.Sleep function

Description:

This function can be used in your script anywhere you want; Suspends the execution of the object for at least the specified interval.

Parameters:

Return value:

Always 0.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" )         ' Create Tcp object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
...
Do while objTcp.ConnectionState = objConstants.asSOCKET_CONNSTATE_CONNECTED
  objTcp.Sleep 500                                              ' Hold for 500 msec
  str = objTcp.ReceiveString
Loop

Tcp.GetErrorDescription function

Description:

GetErrorDescription provides the error description of a given error code.

Parameters:

Return value:

The error description that is associated with the given error code.

Example:

Set objTcp      = CreateObject( "ActiveXperts.Tcp" )            ' Create Tcp object
...
objTcp.Connect "www.thisdoesnotexist.com", 1234
WScript.Echo "LastError: " & objTcp.LastError
WScript.Echo "Error description: " & objTcp.GetErrorDescription( objTcp.LastError )

Tcp.Activate function

Description:

This function activates the ActiveSocket product. A valid registration code is required.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Tcp" ) ' Create Tcp object
objTcp.Activate "xyz", True                             ' Substitute xyz by your own registrationkey
                                                        ' Pass True to make the activation persistent, so you need to call
                                                        ' Activate only once. If you pass False, you need to call
                                                        ' Activate each time the product is started.

7. Udp Object

7.1. Udp Object - Introduction

The ActiveSocket Udp object is based on the Transport Control protocol (UDP) protocol. User Datagram Protocol (UDP) is one of the core protocols of the Internet protocol suite. Using UDP, programs on networked computers can send short messages sometimes known as datagrams (using Datagram Sockets) to one another. UDP is sometimes called the Universal Datagram Protocol or Unreliable Datagram Protocol.

UDP does not guarantee reliability or ordering in the way that TCP does. Datagrams may arrive out of order, appear duplicated, or go missing without notice. Avoiding the overhead of checking whether every packet actually arrived makes UDP faster and more efficient, at least for applications that do not need guaranteed delivery. Time-sensitive applications often use UDP because dropped packets are preferable to delayed packets. UDP's stateless nature is also useful for servers that answer small queries from huge numbers of clients. Unlike TCP, UDP supports packet broadcast (sending to all on local network) and multicasting (send to all subscribers).

To send UDP packages between two machines, one (or more) should act as a server and one should act as a client.
The server process(es) wait(s) for a client to get the data, by listening on a port for an incoming packages of a client.
The client doesn't listen at all; it simply send to a port on the server.

In order to communicate, the server must first create a socket object, and then 'listen' on a specific UDP port to wait for incoming data:

Set objUdp       = CreateObject( "ActiveXperts.Udp" )           ' Create Udp object
Set objConstants = CreateObject( "ActiveXperts.ASConstants" )   ' Create constants object
objUdp.Open "localhost", 1500, True                             ' Listen on port 1500 for incoming data; 
                                                                ' True indicates: receive (instead of send)

On the client side, the client must send UDP data to a server on a specific server-port:

Set objUdp       = CreateObject( "ActiveXperts.Udp" )           ' Create Udp object
Set objConstants = CreateObject( "ActiveXperts.ASConstants" )   ' Create constants object
objUdp.Open "remoteserver", 1500, False                         ' Send to remote machine on port 1500. 
                                                                ' False indicates: no receive but send

Now, the client can send to the server(s) in the following way:

objUdp.SendData "This is a message from client.vbs."            ' Send data

When you're ready, you should close the socket:

objUdp.Close                                                    ' Close

On the client side, the client must connect to a server on a specific server-port:

Set objUdp       = CreateObject( "ActiveXperts.Udp" )           ' Create Udp object
Set objConstants = CreateObject( "ActiveXperts.ASConstants" )   ' Create constants object
objUdp.Connect "remoteserver", 1500                             ' connect on port 1500
If objUdp.LastError = 0 Then
  ' YES, connection established
End If

Now, client and server are peers. They can both send and receive. They can send in the following way:

objUdp.SendData "This is a message from client.vbs."            ' Send data

A process can disconnect the session anytime they want:

objUdp.Disconnect                                               ' Disconnect
' *** client.vbs (full code, VBScript) ***
' Create a socket instance
Set objUdp       = CreateObject ( "ActiveXperts.Udp" )
Set objConstants = CreateObject ( "ActiveXperts.ASConstants" )

' Write some information to console
WScript.Echo "ActiveSocket " & objUdp.Version & " demo."
WScript.Echo "Expiration date: " & objUdp.ExpirationDate & vbCrLf

' Open socket to send to port 1500 on remote server
objUdp.Open "localhost", 1500, False
WScript.Echo "Open, result: " & objUdp.LastError & _
            " (" & objUdp.GetErrorDescription( objUdp.LastError ) & ")"
If( objUdp.LastError <> 0 ) Then
  WScript.Echo "Ready."
  WScript.Quit
End If

str = "This is just a message"
objUdp.SendString str                                           ' Send message
WScript.Echo "SendString '" & str & "': result = " & objUdp.LastError
objUdp.Sleep 100

str = "And this is another message"
objUdp.SendString str                                           ' Send another message
WScript.Echo "SendString '" & str & "': result = " & objUdp.LastError
objUdp.Sleep 100

str = "Quit"
objUdp.SendString str                                           ' Send last message
WScript.Echo "SendString '" & str & "': result = " & objUdp.LastError
objUdp.Sleep 100

objUdp.Close                                                    ' And finally, close the socket

' *** server.vbs (full code, VBScript) ***
' Create a socket instance
Set objUdp       = CreateObject ( "ActiveXperts.Udp" )
Set objConstants = CreateObject ( "ActiveXperts.ASConstants" )

' Write some information to console
WScript.Echo "ActiveSocket " & objUdp.Version & " demo."
WScript.Echo "Expiration date: " & objUdp.ExpirationDate & vbCrLf

' Open socket to receive UDP datagrams on port 1500 on this machine
objUdp.Open "localhost", 1500, True
WScript.Echo "Open, result: " & objUdp.LastError & _
            " (" & objUdp.GetErrorDescription( objUdp.LastError ) & ")"
If( objUdp.LastError <> 0 ) Then
  WScript.Echo "Ready."
  WScript.Quit
End If

Do While str <> "Quit"
  str = objUdp.ReceiveString                                    ' Receive message	
  If( objUdp.LastError = 0 And str <> "" ) Then
      WScript.Echo "ReceiveString: " & str
  End If	
  objUdp.Sleep ( 100 )
Loop

objUdp.Close

7.2. Udp object - Properties and Functions

Property Type In/Out Mand/Opt Description
Build String Out n/a Display build information of ActiveSocket
ExpirationDate String Out n/a Expiration date of ActiveSocket
NewLine String In/Out O The character sequence that forms a newline
IOTimeout Number In/Out O Maximum time of read operations
RemoteAddress String Out n/a The IP address and port number of the remote machine
LastError Number Out n/a Result of the last called function
LogFile String In/Out O Log file; use it for troubleshooting purposes

Function Description
Open Open an UDP socket
Close Close an UDP socket
HasData Is there data available on the socket?
SendString Send a string of ASCII data over the network
SendByte Send a single byte over the network
SendBytes Send raw data over the network
ReceiveString Receive incoming ASCII data on the socket
ReceiveBytes Receive incoming binary data on the socket
ReceiveByte Receive a single byte on the socket
Sleep Suspends the execution of the object for at least the specified interval
GetErrorDescription Get the description of the given error
Activate Activate the product

7.3. Udp Object - Properties

Udp.Version property

Type:

String

Description:

Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objUdp    = CreateObject( "ActiveXperts.Udp" )              ' Create Udp object
Response.Write "Version: " & objUdp.Version

Udp.Build property

Type:

String

Description:

Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objUdp = CreateObject( "ActiveXperts.Udp" )                 ' Create Udp object
WScript.Echo  "Build: " & objUdp.Build

Udp.ExpirationDate property

Type:

String

Description:

Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it. Once you have registered the product, the property holds the empty string ("") value.

Example:

Set objUdp    = CreateObject( "ActiveXperts.Udp" )              ' Create Udp object
Response.Write "ExpirationDate: " & objUdp.ExpirationDate

Udp.NewLine property

Type:

String

Description:

The character sequence that forms a newline. Default value: the CRLF (carriage return / linefeed) string. Most frequent used newline strings:

A newline is used internally by two functions:

Example:

Set objUdp         = CreateObject( "ActiveXperts.Udp" )         ' Create Udp object
...
objUdp.Open "192.168.1.1", 8081, False                          ' Open an UDP socket to send data
If objUdp.LastError = 0 Then
  objUdp.NewLine  = vbCr                                        ' Use CR in the subsequent ReceiveString/SendString calls
                                                                ' transmitted by the WriteString function
  objUdp.SendString "Hello"
End If

Udp.IOTimeout property

Type:

Number

Description:

Maximum IO timeout for read operations (specified in milliseconds). Increase this value when incomplete data is received.

Example:

Set objTcp         = CreateObject( "ActiveXperts.Udp" )         ' Create Udp object
...
objUdp.Connect "192.168.1.1", 8081                              ' Connect to 192.168.1.1 on port 8081
WScript.Echo "Connect, result: " & objTcp.LastError             ' Print the result
...
objUdp.IOTimeout = 1000                                         ' Set IO timeout to 1000ms
...
Wscript.Echo objUdp.ReadString

Udp.RemoteAddress property

Type:

String

Description:

The IP address and port of the remote party that you are connected to.

Example:

Set objUdp         = CreateObject( "ActiveXperts.Udp" )         ' Create Udp object
...
objUdp.Open "192.168.1.1", 8081, True                           ' Open an UDP socket to receive data
If objUdp.LastError = 0 Then
   str = objUdp.ReceiveString
   If( objUdp.LastError = 0 ) Then
     WScript.Echo "Message from:" & objUdp.RemoteAddress        ' Print remote address
   End If
End If

Udp.LastError property

Type:

Number

Description:

The result of a previous called function. Use it to check the result of your last function call. A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.

Example:

Set objUdp     = CreateObject( "ActiveXperts.Udp" )             ' Create Udp object
objUdp.Open "server.mydomain.com", 8081, False
Response.Write "Open, result: " & objUdp.LastError              ' print result of 'Open' call

Udp.LogFile property

Type:

String

Description:

For troubleshooting purposes, you can specify a log file to trace all operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all operations will be written to this log file.

Example:

Set objUdp     = CreateObject( "ActiveXperts.Udp" )             ' Create Udp object
objUdp.LogFile = "c:\file.log                                   ' Specify log file
objUdp.Open "server.mydomain.com", 8081, False
Response.Write "Open, result: " & objUdp.LastError

7.4. Udp Object - Functions

Udp.Open function

Description:

This function opens a socket that can be used to send or receive UDP datagrams.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objUdp         = CreateObject( "ActiveXperts.Udp" )         ' Create Udp object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
objUdp.Open "10.1.1.10", 15000, False                           ' Open socket for sending to 10.1.1.10 on port 15000
If objUdp.LastError <> 0 Then
   WScript.Quit
End If
objUdp.SendString "Hello, world."
objUdp.Close                                                    ' Close socket

Udp.Close function

Description:

Close a socket that was opened using the Open function.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objUdp         = CreateObject( "ActiveXperts.Udp" )         ' Create Udp object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
objUdp.Open "10.1.1.10", 15000, False                           ' Open socket for sending to 10.1.1.10 on port 15000
If objUdp.LastError <> 0 Then
   WScript.Quit
End If
objUdp.SendString "Hello, world."
objUdp.Close                                                    ' Close socket
End If

Udp.HasData function

Description:

Check if there's incoming data available.

Parameters:

Return value:

True if there's data available; otherwise False.

Example:

Set objUdp         = CreateObject( "ActiveXperts.Udp" )         ' Create Udp object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
...
Do While objUdp.ConnectionState = objConstants.asSOCKET_CONNSTATE_CONNECTED
  If objUdp.HasData Then                                        ' Data available ?
    str = objUdp.ReceiveString
    WScript.Echo "Received: " & str
    objUdp.Sleep 100
  End If
Loop

Udp.SendString function

Description:

This function sends a string of printable ASCII data to the (remote) server.
Telnet functions need a NewLine after the data string. ActiveSocket will automatically append the NewLine to the string.
Use the SendByte or SendBytes functions to send binary data or strings without NewLine sequence over the network.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objUdp         = CreateObject( "ActiveXperts.Udp" )         ' Create Udp object
...
objUdp.Open "10.1.1.10", 15000, False                           ' Open socket for sending to 10.1.1.10 on port 15000
If objUdp.LastError = 0 Then
  objUdp.SendString "Hello"
  If objUdp.LastError = 0 Then
    WScript.Echo "SendString was successful"
  Else
    WScript.Echo "SendString failed"
  End If
  objUdp.Close
End If

Udp.SendByte function

Description:

This function sends a single byte over the network. To send multiple bytes at once, use the SendBytes function. SendByte is ideal to send binary data; for ASCII data, it's recommended to use the SendString function.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objUdp         = CreateObject( "ActiveXperts.Udp" )         ' Create Udp object
...
objUdp.Open "10.1.1.10", 15000, False                           ' Open socket for sending to 10.1.1.10 on port 15000
If objUdp.LastError = 0 Then
  objUdp.SendByte &H01                                          ' Send one byte
  objUdp.SendByte &H04                                          ' Send one byte
  objUdp.SendByte &H00                                          ' Send one byte
End If

Udp.SendBytes function

Description:

This function sends the specified bytes over the network.
Use the 'SendBytes' function to send binary data. To send ASCII (displayable) data, use the SendString function.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objUdp         = CreateObject( "ActiveXperts.Udp" )         ' Create Udp object
...
objUdp.Open "10.1.1.10", 15000, False                           ' Open socket for sending to 10.1.1.10 on port 15000
If objUdp.LastError = 0 Then
  objUdp.SendBytes "Hello"                                      ' Send a stream of bytes
End If

Udp.ReceiveString function

Description:

Read ASCII data from socket until a NewLine is read from the device or a timeout has elapsed.
NOTE: Use the ReceiveBytes or ReceiveByte functions to receive binary data from the (remote) computer).

Parameters:

Return value:

Empty string if there's no incoming data available; otherwise, the ASCII string that was read from the socket. Check LastError property to see if the function was completed successfully.

Example:

Set objUdp         = CreateObject( "ActiveXperts.Udp" )         ' Create Udp object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
...
objUdp.Open "localhost", 15000, True                            ' Open socket for receiving on port 15000
Do
  str = objUdp.ReceiveString                                    ' Receive messages in an endless loop
  If( objUdp.LastError = 0 And str <> "" ) Then
    WScript.Echo "Received: " & str
    objUdp.Sleep 100
  End If
Loop

Udp.ReceiveBytes function

Description:

Read binary data from socket (use the ReceiveString function to receive ASCII data from the network).
ReceiveBytes receives and returns all the binary data from the network.

Parameters:

Return value:

The received datastring. Check LastError property to see if the function was completed successfully.

Example:

Set objUdp         = CreateObject( "ActiveXperts.Udp" )         ' Create Udp object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
...
objUdp.Open "localhost", 15000, True                            ' Open socket for receiving on port 15000
Do
  data = objUdp.ReceiveBytes                                    ' Receive messages in an endless loop
  If( objUdp.LastError = 0 And data <> "" ) Then
    WScript.Echo "Received: " & data
    objUdp.Sleep 100
  End If
Loop

Udp.ReceiveByte function

Description:

Receive a single byte of binary data from the socket. Use the ReceiveBytes function to receive all binary data from the (remote) computer.

Parameters:

Return value:

The byte received. Check LastError property to see if the function was completed successfully.

Example:

Set objUdp         = CreateObject( "ActiveXperts.Udp" )         ' Create Udp object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
...
objUdp.Open "localhost", 15000, True                            ' Open socket for receiving on port 15000
Do
  byte = objUdp.ReceiveByte                                     ' Receive messages in an endless loop
  If( objUdp.LastError = 0 And byte <> "" ) Then
    WScript.Echo "Received: " & byte
  End If
Loop

Udp.Sleep function

Description:

This function can be used in your script anywhere you want; Suspends the execution of the object for at least the specified interval.

Parameters:

Return value:

Always 0.

Example:

Set objUdp         = CreateObject( "ActiveXperts.Udp" )         ' Create Udp object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
...
objUdp.Open "localhost", 15000, True                            ' Open socket for receiving on port 15000
Do
  data = objUdp.ReceiveBytes                                    ' Receive messages in an endless loop
  If( objUdp.LastError = 0 And data <> "" ) Then
    WScript.Echo "Received: " & data
    objUdp.Sleep 100
  End If
Loop

Udp.GetErrorDescription function

Description:

GetErrorDescription provides the error description of a given error code.

Parameters:

Return value:

The error description that is associated with the given error code.

Example:

Set objUdp      = CreateObject( "ActiveXperts.Udp" )            ' Create Udp object
...
objUdp.Open "www.thisdoesnotexist.forsure", 1234, False
WScript.Echo "LastError: " & objUdp.LastError
WScript.Echo "Error description: " & objUdp.GetErrorDescription( objUdp.LastError )

Udp.Activate function

Description:

This function activates the ActiveSocket product. A valid registration code is required.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objUdp         = CreateObject( "ActiveXperts.Udp" ) ' Create Udp object
objUdp.Activate "xyz", True                             ' Substitute xyz by your own registrationkey
                                                        ' Pass True to make the activation persistent, so you need to call
                                                        ' Activate only once. If you pass False, you need to call
                                                        ' Activate each time the product is started.

8. Http Object

8.1. Http Object - Introduction

Today, there are many software packages available to check web sites, like availability, contents, bandwidth, changes, etc..
However, most of these software tools are stand-alone packages, without scripting options. ActiveSocket is very well suited for scripting and embedding in applications.

The ActiveSocket Http object allows you to read web pages completely, so you can perform your own content checking. Use the ActiveSocket Http object to:

The ActiveSocket Http object doesn't require direct Internet access; it can operate through a proxy server (incl. support for proxy authentication). It also supports SSL secure web sites, including authentication.

Here is a small example (in VBScript) to show how to use the Http object:

Set objHttp = CreateObject("ActiveXperts.Http")                 ' Create HTTP object
objHttp.Connect( "www.activexperts.com/products" )              ' Connect to a remote server
WScript.Echo "Connect, result: " & objHttp.LastError
If( objHttp.LastError <> 0 ) Then
   WScript.Quit
End If

' Connection esablished; ready to read data
strData = objHttp.ReadData                                      ' Read data stream
If( objHttp.LastError <> 0 ) Then
   WScript.Echo "Error " & objHttp.LastError                    ' Failed to read data, print the error
Else
   WScript.Echo strData                                         ' Show data
End If

objHttp.Disconnect                                              ' Disconnect
WScript.Echo "Ready."

8.2. Http object - Properties and Functions

Property Type In/Out Mand/Opt Description
Version String Out n/a Version number of ActiveSocket
Build String Out n/a Display build information of ActiveSocket
ExpirationDate String Out n/a Expiration date of ActiveSocket
LastError Number Out n/a Result of the last called function
UseSSL Bool In/Out n/a Access the page through SSL
UsePost Bool In/Out n/a Specify to use HTTP-POST instead of HTTP-GET
PostData String In/Out O Data to send with HTTP POST
RequestTimeout Number In/Out O Timeout value for HTTP requests
KeepAlive Bool In/Out n/a Specify to use the keepalive flag in the HTTP header
HttpLibrary String In/Out O The preferred Http interface library
ProxyServer String In/Out O Use a proxy server
ProxyAccount String In/Out O Use this account for proxy authentication
ProxyPassword String In/Out O Use this password for proxy authentication
WebAccount String In/Out O Use this account to authenticate at the web site
WebPassword String In/Out O Use this password to authenticate at the web site
LogFile String In/Out O Log file; use it for troubleshooting purposes

Function Description
Clear Reset all properties to default
Connect Connect to a web site
Disconnect Disconnect from a web site
ReadHeader Read HTTP header
ReadData Read data from the web page
WriteData Send data to the web page
GetErrorDescription Get the error description
Sleep Suspends the execution of the object for at least the specified interval
Activate Activate the product

8.3. Http Object - Properties

Http.Version property

Type:

String

Description:

Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objHttp = CreateObject("ActiveXperts.Http")
WScript.Echo  "Version: " & objHttp.Version

Http.Build property

Type:

String

Description:

Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objHttp = CreateObject( "ActiveXperts.Http" )                 ' Create Http object
WScript.Echo  "Build: " & objHttp.Build

Http.ExpirationDate property

Type:

String

Description:

Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it. Once you have registered the product, the property holds the empty string ("") value.

Example:

Set objHttp    = CreateObject( "ActiveXperts.Http" )              ' Create Http object
Response.Write "ExpirationDate: " & objHttp.ExpirationDate

Http.LastError property

Type:

Number

Description:

The result of a previous called function. Use it to check the result of your last function call. A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.

Example:

Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.Connect "www.activexperts.com"
WScript.Echo "LastError: " & objHttp.LastError

Http.UseSSL property

Type:

Boolean

Description:

Set this property to indicate that the Connect function must access the page through SSL. Connect discards the 'http://' and 'https://' prefixes, so settings the 'UseSSL' property is the only way to tell the Http object to use SSL.

Example:

Set objHttp = CreateObject("ActiveXperts.Http")
objHttp.UseSSL = True
...
objHttp.Connect "www.activexperts.com" ' To access https://www.activexperts.com

Http.UsePost property

Type:

Boolean

Description:

Set this property to indicate that the Connect function must request the page using HTTP-POST. HTTP-POST is used to send a large number of bytes as parameters to a webserver.
The default value is disabled (use HTTP-GET).

Example:

Set objHttp = CreateObject("ActiveXperts.Http")
objHttp.UsePost = True
...
objHttp.Connect "www.activexperts.com/activsocket/postdemo/default.asp?parameter=200" ' HTTP/Post

Http.PostData property

Type:

String

Description:

When the UsePost property is set, you can use this property to send additional data with the HTTP POST request.

Example:

Set objHttp = CreateObject("ActiveXperts.Http")
objHttp.UsePost  = True
objHttp.PostData = "a1=1;a2=2"
...
objHttp.Connect "www.activexperts.com/activsocket/postdemo/default.asp?parameter=200" ' HTTP/Post

Http.RequestTimeout property

Type:

Number

Description:

By default the HTTP request timeout is set to 10000 ms. For large webpages, or pages that need to do some processing, you can use this property to increase the timeout. The value is specified in milliseconds.

Example:

Set objHttp = CreateObject("ActiveXperts.Http")
objHttp.RequestTimeout = 20000
...
objHttp.Connect "www.activexperts.com/activsocket/postdemo/default.asp?parameter=200"

Http.KeepAlive property

Type:

Boolean

Description:

Set this property to indicate that 'KeepAlive' value in the HTTP header is set to TRUE. This required for some rarely used authentication algorithms.

Example:

Set objHttp = CreateObject("ActiveXperts.Http")
objHttp.KeepAlive = True
...
objHttp.Connect "www.activexperts.com/activsocket/postdemo/default.asp?parameter=200"

Http.HttpLibrary property

Type:

Number

Description:

ActiveSocket makes use of the WinHTTP library of the operating system. By default, the 'HttpLibrary' property is emtpy, and ActiveSocket will attempt to load WinHTTP5.dll. If WinHTTP5.dll fails to load, it will attempt to load WinHTTP.dll.
If you prefer another WinHTTP library, you can set the 'HttpLibrary' property. If set, ActiveSocket will ONLY attempt to load the specified library, it will not try other libraries after that. The 'HttpLibrary' property is used by the Connect function, so you must assign a value to it BEFORE calling the Connect function.

Example:

Set objHttp         = CreateObject("ActiveXperts.Http")
objHttp.HttpLibrary = "winhttp.dll"     ' Load winhttp.dll
...
objHttp.Connect "www.activexperts.com"

Http.ProxyServer,
Http.ProxyAccount,
Http.ProxyPassword properties

Type:

String

Description:

If your Internet configuration requires access to a proxy server, you must assign the host name or IP address of the proxy server to the 'ProxyServer' property. Optionally, if proxy authentication is required, assign the proxy authentication values to the 'ProxyAccount' and 'ProxyPassword' properties. The proxy properties are used by the Connect function, so you must assign values to the proxy properties BEFORE calling the Connect function.

Example:

Set objHttp           = CreateObject("ActiveXperts.Http")
objHttp.ProxyServer   = "proxy01.intranet.dom"  ' Access through a proxy
objHttp.ProxyAccount  = "mjackson"              ' Proxy authentication required
objHttp.ProxyPassword = "mjackson1"             ' Proxy authentication required
...
objHttp.Connect "www.activexperts.com"

Http.WebAccount,
Http.WebPassword properties

Type:

String

Description:

If access to the web page requires authentication, you must assign the 'WebAccount' and 'WebPassword' properties. The 'WebAccount' and 'WebPassword' properties are used by the Connect function, so you must assign values to these properties BEFORE calling the Connect function.

Example:

Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.WebAccount = "user_a" ' Website requires authentication
objHttp.WebPassword = "password_a" ' Website requires authentication
objHttp.Connect "www.activexperts.com:80/about"

Http.LogFile

Type:

String

Description:

For troubleshooting purposes, you can specify a log file to trace all operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all operations will be written to this log file.

Example:

Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.LogFile = "c:\file.log"
objHttp.Connect "www.activexperts.com:80/about"

8.4. Http Object - Functions

Http.Clear function

Description:

Resets all properties to the initial value.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

objHttp.Connect "www.activexperts.com/products"
If( objHttp.LastError = 0 ) Then
  ...
End If

Example:

Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.Connect "www.activexperts.com:8080/products/"
If( objHttp.LastError = 0 ) Then
  ...
End If

Http.Connect function

Description:

Connect to a web page. You must connect to a web page before you can use the ReadData to actually read the data from the page. The 'Connect' function requires one parameter: the URL. The 'http://' and 'https://' prefixes are ignored by the 'Connect' function. You can include a port number and a relative path in the URL.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

objHttp.Connect "www.activexperts.com/products"
If( objHttp.LastError = 0 ) Then
  ...
End If

Example:

Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.Connect "www.activexperts.com:8080/products/"
If( objHttp.LastError = 0 ) Then
  ...
End If

Http.Disconnect function

Description:

Disconnect from a web site. You must disconnect from a web page when you don't want to read data from the page anymore. The 'Disconnect' function only disconnects a session if you already made a connection to the page though the Connect function. If there is no connection, 'Disconnect' returns immediately with no error.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.Connect "www.activexperts.com/products"
If( objHttp.LastError = 0 ) Then
  ...
  objHttp.Disconnect
End If

Http.ReadData function

Description:

Read all data from the web page. You must connect to a web page before you can read the data from the page.

Parameters:

Return value:

The data that was read from the web page. If the function fails, an empty string is retunred and LastError property is set.

Example:

Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.Connect "www.activexperts.com"
If( objHttp.LastError = 0 )
  strData = objHttp.ReadData
  If( objHttp.LastError = 0 )
    WScript.Echo strData
  End If
End If

Http.ReadHeader function

Description:

Read the HTTP header of the site you are connecting to. You must connect to a web page before you can read the HTTP header from the remote site.

Parameters:

Return value:

The header that was read from the site. If the function fails, an empty string is retunred and LastError property is set.

Example:

Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.Connect "www.activexperts.com"
If( objHttp.LastError = 0 )
  strData = objHttp.ReadHeader( 1 )             '  1 means: Content-type
  WScript.Echo strData
  strData = objHttp.ReadHeader( 3 )             '  3 means: Content-ID
  WScript.Echo strData
  strData = objHttp.ReadHeader( 35 )            ' 35 means: Referer
  WScript.Echo strData
End If

Http.WriteData function

Description:

Write data to the web page. You must connect to a web page before you can write data to the webserver.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.Connect "www.activexperts.com"
If( objHttp.LastError = 0 )
  objHttp.WriteData "A5B3D7F8"
End If

Http.GetErrorDescription function

Description:

GetErrorDescription provides the error description of a given error code.

Parameters:

Return value:

The error description that is associated with the given error code.

Example:

Set objHttp = CreateObject("ActiveXperts.Http")
...
objHttp.Connect "www.thispagedoesnotexist.dom/about"
WScript.Echo "LastError: "         & objHttp.LastError
WScript.Echo "Error description: " & objHttp.GetErrorDescription( objHttp.LastError )

Http.Sleep function

Description:

This function can be used in your script anywhere you want; Suspends the execution of the object for at least the specified interval.

Parameters:

Return value:

Always 0.

Example:

Set objHttp        = CreateObject( "ActiveXperts.Http" )         ' Create Http object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" )  ' Create constants object
...
objHttp.Sleep 500

Http.Activate function

Description:

This function activates the ActiveSocket product. A valid registration code is required.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objHttp         = CreateObject( "ActiveXperts.Http" ) ' Create Http object
objHttp.Activate "xyz", True                             ' Substitute xyz by your own registrationkey
                                                        ' Pass True to make the activation persistent, so you need to call
                                                        ' Activate only once. If you pass False, you need to call
                                                        ' Activate each time the product is started.

9. FtpServer / FtpFile Objects

9.1. Introduction

FTP stands for File Transfer Protocol: a communication standard which allows computers to transfer files back and forth in spite of differences in how different operating systems handle file names, directories and file formats.

The local (client) computer is the one you're directly connected to, and the remote (server) computer is the one that you want to get files from or put files to. You need to specify the Internet address of the remote computer, e.g. ftp.activexperts-labs.com.

Some sites maintain archives of files for public use, permitting access using the username anonymous. Usually you are asked to enter your real e-mail address as the password. If a site is not using anonymous FTP, you must provide the username and password which has been assigned to you for that computer.

FTP programmes have different methods of handling plain-text files and binary files. The plain-text mode attempts to correct for the different ways that different operating systems handle line breaks in text files, while the binary mode ensures that all of the special non-printing bytes are transferred without change. HTML files are plain-text files, while word-processing documents and images are binary files.

The following sample (VBScript) shows how the FtpServer and FtpFile objects can be used to list files in a specific directory on an FTP server:

Set objFtpServer = CreateObject ( "ActiveXperts.FtpServer" )

objFtpServer.Connect "ftp.activexperts-labs.com","anonymous","" ' Connect to the FTP server using the anonymous account 
Wscript.Echo "Connect, result: " & objFtpServer.LastError
If( objFtpServer.LastError <> 0 ) Then                          ' If connect failed then quit
   WScript.Quit
End If

objFtpServer.ChangeDir "samples/ASocket/Visual Basic/Telnet"    ' Change directory
Wscript.Echo "ChangeDir, result: " & objFtpServer.LastError
If( objFtpServer.LastError <> 0 ) Then                          ' If ChangeDir fails then disconnect and quit
   objFtpServer.Disconnect
   WScript.Quit
End If

Set objFtpFile = objFtpServer.FindFirstFile()                   ' Iterate over all files in dir. Start with first file
While( objFtpServer.LastError = 0 )
   WScript.Echo "Name: " & objFtpFile.Name                      ' Display file name
   WScript.Echo "IsDirectory: " & objFtpFile.IsDirectory        ' Display directory or file
   WScript.Echo "Size: " & objFtpFile.Size                      ' Display file size
   WScript.Echo "Date: " & objFtpFile.Date                      ' Display file date
    
   ' To save the file, call the GetFile function. 
   ' strSaveAs = "C:\temp\" & objFtpFile.Name
   ' objFtpServer.GetFile objFtpFile.Name, strSaveAs
   ' Wscript.Echo "Save file, result: " & objFtpServer.LastError

   ' To delete a file, call the DeleteFile function. 
   ' objFtpServer.DeleteFile objFtpFile.Name
   ' Wscript.Echo "Delete, result: " & objFtpServer.LastError

   Set objFtpFile = objFtpServer.FindNextFile()                 ' Next file
Wend

objFtpServer.Disconnect                                         ' Disconnect

9.2. FtpFile object - Properties and Functions

Property Type In/Out Mand/Opt Description
Name String Out n/a Filename
IsDirectory Boolean Out n/a Is the file a directory (True) or a file (False)
Size Number Out n/a Size of file (in bytes)
DateSeconds Number Out n/a Creation date of the file (in seconds after 1/1/1970)
Date String Out n/a Creation date of the file (as a friendly string)

Function Description
None No functions defined for the FtpFile object

9.3. FtpFile Object - Properties

FtpFile.Name property

Type:

String

Description:

File name.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" )     ' Create a new FtpServer instance
...
objFtpServer.Connect( "ftp01", "myaccount", "mypassword" )      ' Connect to the FTP server    
...
Set objFtpFile = objFtpServer.FindFirstFile()                   ' Get first file in the directory
If( objFtpServer.LastError = 0 ) Then                           
   WScript.Echo "Name   : " & objFtpFile.Name                   ' Display name of the file
   WScript.Echo "IsDirectory  : " & objFtpFile.IsDirectory      
   WScript.Echo "Size (in bytes) : " & objFtpFile.Size         
   WScript.Echo "DateSeconds : " & objFtpFile.DateSeconds      
   WScript.Echo "Date : " & objFtpFile.Date                     
End If
...
objFtpServer.Disconnect                                         ' Disconnect

FtpFile.IsDirectory property

Type:

Boolean

Description:

True indicates a directory, False indicates a file.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" )     ' Create a new FtpServer instance
...
objFtpServer.Connect( "ftp01", "myaccount", "mypassword" )      ' Connect to the FTP server    
...
Set objFtpFile = objFtpServer.FindFirstFile()                   ' Get first file in the directory
If( objFtpServer.LastError = 0 ) Then                           
   WScript.Echo "Name   : " & objFtpFile.Name                   
   WScript.Echo "IsDirectory  : " & objFtpFile.IsDirectory      ' Display: Directory or File
   WScript.Echo "Size (in bytes) : " & objFtpFile.Size          
   WScript.Echo "DateSeconds : " & objFtpFile.DateSeconds       
   WScript.Echo "Date : " & objFtpFile.Date                     
End If
...
objFtpServer.Disconnect                                         ' Disconnect

FtpFile.Size property

Type:

Number

Description:

Size (in bytes) of the file.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" )     ' Create a new FtpServer instance
...
objFtpServer.Connect( "ftp01", "myaccount", "mypassword" )      ' Connect to the FTP server    
...
Set objFtpFile = objFtpServer.FindFirstFile()                   ' Get first file in the directory
If( objFtpServer.LastError = 0 ) Then                           
   WScript.Echo "Name   : " & objFtpFile.Name                   
   WScript.Echo "IsDirectory  : " & objFtpFile.IsDirectory     
   WScript.Echo "Size (in bytes) : " & objFtpFile.Size          ' Display size in bytes
   WScript.Echo "DateSeconds : " & objFtpFile.DateSeconds       
   WScript.Echo "Date : " & objFtpFile.Date                    
End If
...
objFtpServer.Disconnect                                         ' Disconnect

FtpFile.DateSeconds property

Type:

Number

Description:

Creation date and time of the file, in seconds after 1/1/1970.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" )     ' Create a new FtpServer instance
...
objFtpServer.Connect( "ftp01", "myaccount", "mypassword" )      ' Connect to the FTP server    
...
Set objFtpFile = objFtpServer.FindFirstFile()                   ' Get first file in the directory
If( objFtpServer.LastError = 0 ) Then                           
   WScript.Echo "Name   : " & objFtpFile.Name                   
   WScript.Echo "IsDirectory  : " & objFtpFile.IsDirectory      
   WScript.Echo "Size (in bytes) : " & objFtpFile.Size         
   WScript.Echo "DateSeconds : " & objFtpFile.DateSeconds       ' Display creation date/time in seconds after 1/1/1970
   WScript.Echo "Date : " & objFtpFile.Date                     
End If
...
objFtpServer.Disconnect                                         ' Disconnect

FtpFile.Date property

Type:

String

Description:

Creation date and time of the file, as a friendly string.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" )     ' Create a new FtpServer instance
...
objFtpServer.Connect( "ftp01", "myaccount", "mypassword" )      ' Connect to the FTP server    
...
Set objFtpFile = objFtpServer.FindFirstFile()                   ' Get first file in the directory
If( objFtpServer.LastError = 0 ) Then                           
   WScript.Echo "Name   : " & objFtpFile.Name                  
   WScript.Echo "IsDirectory  : " & objFtpFile.IsDirectory      
   WScript.Echo "Size (in bytes) : " & objFtpFile.Size    
   WScript.Echo "DateSeconds : " & objFtpFile.DateSeconds     
   WScript.Echo "Date : " & objFtpFile.Date                     ' Display creation date/time as a friendly string
End If
...
objFtpServer.Disconnect                                         ' Disconnect

9.4. FtpServer object - Properties and Functions

Property Type In/Out Mand/Opt Description
Version String Out n/a Version number of ActiveSocket
Build String Out n/a Display build information of ActiveSocket
ExpirationDate String Out n/a Expiration date of ActiveSocket
HostPort Number In/Out O TCP port of the remote FTP server. Default: 21
PassiveMode Boolean In/Out O Specifies how to connect: passive (default) or active
BinaryTransfer Boolean In/Out O Specifies how to transfer files: binary (default) or ASCII
LastError Number Out n/a Result of the last called function
LastResponse String Out n/a Last response from FTP server
LogFile String In/Out O Log file for troubleshooting purposes

Function Description
Clear Reset all properties to their default values
Connect Connect to a remote FTP server
Disconnect Close the connection
GetCurrentDir Retrieve the current directory
ChangeDir Change directory
CreateDir Create directory
RenameDir Rename directory
DeleteDir Delete directory
FindFile Find a file in the current directory
FindFirstFile Find first file in the current directory
FindNextFile Find next file in the current directory
RenameFile Rename a file in the current directory
DeleteFile Delete a file in the current directory
GetFile Download (get) a file from the current directory
PutFile Upload (put) a file to the current directory
GetErrorDescription Get the description of the given error
Sleep Suspends the execution of the object for at least the specified interval
Activate Suspends the execution of the object for at least the specified interval

9.5. FtpServer Object - Properties

FtpServer.Version property

Type:

String

Description:

Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objFtpServer = CreateObject("ActiveXperts.FtpServer")       ' Create a new FtpServer instance
WScript.Echo  "Version: " & objFtpServer.Version

FtpServer.Build property

Type:

String

Description:

Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" )     ' Create a new FtpServer object
WScript.Echo  "Build: " & objFtpServer.Build

FtpServer.ExpirationDate property

Type:

String

Description:

Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" )     ' Create a new FtpServer instance
WScript.Echo "ExpirationDate: " & objFtpServer.ExpirationDate

FtpServer.HostPort property

Type:

Number

Description:

TCP port number to identify a (remote) FTP server. If you don't specify the 'HostPort' property, port 21 (default FTP port) is used.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" )     ' Create a new FtpServer instance
...
objFtpServer.HostPort = 8021                                    ' Use port 8021 instead of default port 21
objFtpServer.Connect "ftpserver1", "account", "pwd"             ' Connect to host ftpserver1 on port 8021
...

FtpServer.PassiveMode property

Type:

Boolean

Description:

Specifies the way to connect to the remote FTP server: in Passive mode or in Active mode. Default value: True (Passive)

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" )     ' Create a new FtpServer instance
...
objFtpServer.PassiveMode = False                                ' Use Active mode instead of the default Passive mode
objFtpServer.Connect "ftpserver1", "account", "pwd"             ' Connect to host ftpserver1 in Active mode
...

FtpServer.BinaryTransfer property

Type:

Boolean

Description:

Specifies the way files are transfered when downloading (GetFile) or uploading (PutFile) files. Default value: True, indicating that files are tranferred in binary mode by default.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" )     ' Create a new FtpServer instance
...
objFtpServer.Connect "ftpserver1", "account", "pwd"         ' Connect to host ftpserver1
...
objFtpServer.BinaryMode = False                             ' Files transfer in ASCII mode when using GetFile/PutFile
Set objFtpFile = objFtpServer.GetFile( "c:\temp\log1.txt", "/logfiles/log1.txt" )  ' Download log1.txt in ASCII mode

FtpServer.LastError property

Type:

Number

Description:

The result of a previous called function. Use it to check the result of your last function call. A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" )     ' Create a new FtpServer instance
...
objFtpServer.Connect "ftpserver1", "account", "pwd"             ' Connect to host ftpserver1
WScript.Echo "LastError: " & objFtpServer.LastError
...

FtpServer.LastResponse property

Type:

String

Description:

The last response of an FTP operation is stored in the 'LastResponse' property. It can be used for troubleshooting purposes.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" )     ' Create a new FtpServer instance
...
objFtpServer.Connect "ftpserver1", "account", "pwd"             ' Connect to host ftpserver1
WScript.Echo "LastResponse: " & objFtpServer.LastResponse       ' Display the last response from the FTP server
...

FtpServer.LogFile property

Type:

String

Description:

For troubleshooting purposes, you can specify a log file to trace all FTP operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all FTP operations will be written to this log file.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" )     ' Create a new FtpServer instance
objFtpServer.LogFile = "C:\Ftp.log"                             ' Write all FTP operations to the specified log file
...
objFtpServer.Connect "ftpserver1", "account", "pwd"             ' Connect to host ftpserver1
...

9.6. FtpServer Object - Functions

FtpServer.Clear function

Description:

Resets all properties to the initial, default values.

Parameters:

Return value:

Always 0.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance
objFtpServer.Connect "ftpserver1", "account", "pwd"         ' Connect to host ftpserver1
...
objFtpServer.Disconnect                                     ' Disconnect
objFtpServer.Clear                                          ' Clear properties before connecting to another FTP server
objFtpServer.Connect "ftpserver2", "account", "pwd"         ' Connect to host ftpserver2

FtpServer.Connect function

Description:

Call this function to connect to a remote FTP server. By default, a Passive connection will be established. If you want to establish a connection in Active mode, you should set the PassiveMode flag to False.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance
objFtpServer.Connect "ftpserver1", "account", "pwd"         ' Connect to host ftpserver1
If( objFtpServer.LastError = 0 ) Then
   ...
   objFtpServer.ChangeDir( "/pictures" )
   ...
   objFtpServer.Disconnect
End If

FtpServer.Disconnect function

Description:

Call this function to close a connnection that was established using the Connect function.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance
objFtpServer.Connect "ftpserver1", "account", "pwd"         ' Connect to host ftpserver1
If( objFtpServer.LastError = 0 ) Then
   ...
   objFtpServer.Disconnect                                  ' Close the session
End If

FtpServer.GetCurrentDir function

Description:

The directory string. If the function fails, an empty string is returned and the LastError property is set to a non-zero value indicating the reason for failing.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance
objFtpServer.Connect "ftpserver1", "account", "pwd"         ' Connect to host ftpserver1
If( objFtpServer.LastError = 0 ) Then
   ...
   strCurrentDir = objFtpServer.GetCurrentDir()             ' Retrieve current directory
   If( objFtpServer.LastError = 0 ) Then
      WScript.Echo "Current Directory: " & strCurrentDir
   End If
   objFtpServer.Disconnect                                  ' Close the session
End If

FtpServer.ChangeDir function

Description:

Change the current directory on the remote FTP server. You can use a fully qualified directory name, or a plain directory name.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance
objFtpServer.Connect "ftpserver1", "account", "pwd"         ' Connect to host ftpserver1
If( objFtpServer.LastError = 0 ) Then
   ...
   objFtpServer.ChangeDir( "/pictures" )                    ' Change directory to: /pictures
   objFtpServer.ChangeDir( "family" )                       ' Change directory to: /pictures/family
   ...
   objFtpServer.ChangeDir( "/pictures/friends" )            ' Change directory to: /pictures/friends
   ...
   objFtpServer.Disconnect                                  ' Close the session
End If

FtpServer.CreateDir function

Description:

Create a new directory on the remote FTP server in the directory indicated by GetCurrentDir.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance
objFtpServer.Connect "ftpserver1", "account", "pwd"         ' Connect to host ftpserver1
If( objFtpServer.LastError = 0 ) Then
   ...
   objFtpServer.ChangeDir( "/pictures" )                    ' Change directory to: /pictures
   objFtpServer.CreateDir( "family" )                       ' Create new directory 'family'
   ...
   objFtpServer.Disconnect                                  ' Close the session
End If

FtpServer.RenameDir function

Description:

Rename directory.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance
objFtpServer.Connect "ftpserver1", "account", "pwd"         ' Connect to host ftpserver1
If( objFtpServer.LastError = 0 ) Then
   ...
   objFtpServer.RenameDir( "pictures", "images" )           ' Rename directory 'pictures' into 'images'
   ...
   objFtpServer.Disconnect                                  ' Close the session
End If

FtpServer.DeleteDir function

Description:

Delete a directory.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance
objFtpServer.Connect "ftpserver1", "account", "pwd"         ' Connect to host ftpserver1
If( objFtpServer.LastError = 0 ) Then
   ...
   objFtpServer.ChangeDir( "/pictures" )                    ' Change directory to: /pictures
   objFtpServer.DeleteDir( "family" )                       ' Delete directory 'family'
   ...
   objFtpServer.Disconnect                                  ' Close the session
End If

FtpServer.FindFile function

Description:

Find a file. You can use a plain filename (the file will then be retrieved from the current directory) or you can use a fully qualified filename.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance
objFtpServer.Connect "ftpserver1", "account", "pwd"         ' Connect to host ftpserver1
If( objFtpServer.LastError = 0 ) Then
   Set objFtpFile1 = objFtpServer.FindFile( "/pictures/picture1.jpg") ' Find file using a fully qualified filename
   ...
   objFtpServer.ChangeDir( "/pictures" )
   Set objFtpFile2 = objFtpServer.FindFile( "picture2.jpg")           ' Find file using a plain filename
   objFtpServer.Disconnect                                  ' Close the session
End If

FtpServer.FindFirstFile,
FtpServer.FindNextFile functions

Description:

Iterate of all files and directories in the current directory. The 'FindFirstFile' function retrieves the first file/directory. You can call 'FindNextFile' until there are no more files/directories.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance
objFtpServer.Connect "ftpserver1", "account", "pwd"         ' Connect to host ftpserver1
If( objFtpServer.LastError = 0 ) Then
   Set objFtpFile = objFtpServer.FindFirstFile()
   While( objFtpServer.LastError = 0 )
       WScript.Echo "File: " & objFtpFile.Name              ' Display filename (or directoryname)
       Set objFtpFile = objFtpServer.FindNextFile()
   WEnd
   objFtpServer.Disconnect                                  ' Close the session
End If

FtpServer.RenameFile function

Description:

Rename file.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance
objFtpServer.Connect "ftpserver1", "account", "pwd"         ' Connect to host ftpserver1
If( objFtpServer.LastError = 0 ) Then
   ...
   objFtpServer.ChangeDir( "/pictures" )                    ' Change directory to: /pictures
   objFtpServer.Rename( "old.jpg", "new.jpg" )              ' Rename 'old.jpg' into 'new.jpg'
   ...
   objFtpServer.Disconnect                                  ' Close the session
End If

FtpServer.DeleteFile function

Description:

Delete file.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance
objFtpServer.Connect "ftpserver1", "account", "pwd"         ' Connect to host ftpserver1
If( objFtpServer.LastError = 0 ) Then
   ...
   objFtpServer.ChangeDir( "/pictures" )                    ' Change directory to: /pictures
   objFtpServer.Rename( "picture1.jpg" )                    ' Delete 'picture1.jpg'
   ...
   objFtpServer.Disconnect                                  ' Close the session
End If

FtpServer.GetFile function

Description:

Download a file from the FTP server.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance
objFtpServer.Connect "ftpserver1", "account", "pwd"         ' Connect to host ftpserver1
If( objFtpServer.LastError = 0 ) Then
   ...
   objFtpServer.ChangeDir( "/pictures" )                    ' Change directory to: /pictures
   objFtpServer.GetFile( "picture1.jpg", "c:\pictures\file1.jpg" )           ' Download 'picture1.jpg'
   ...
   objFtpServer.ChangeDir( "/" )                            ' Change directory to: /
   objFtpServer.GetFile( "/pictures/picture1.jpg", "c:\pictures\file1.jpg" ) ' Download 'picture2.jpg'
   objFtpServer.Disconnect                                  ' Close the session
End If

FtpServer.PutFile function

Description:

Upload a file to the FTP server.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance
objFtpServer.Connect "ftpserver1", "account", "pwd"         ' Connect to host ftpserver1
If( objFtpServer.LastError = 0 ) Then
   ...
   objFtpServer.ChangeDir( "/pictures" )                    ' Change directory to: /pictures
   objFtpServer.PutFile( "c:\pictures\picture3.jpg" )       ' Upload 'picture3.jpg'
   ...
   objFtpServer.PutFile( "c:\pictures\picture4.jpg", "/pictures/picture4.jpg" )    ' Upload 'picture4.jpg'
End If

FtpServer.GetErrorDescription function

Description:

GetErrorDescription provides the error description of a given error code.

Parameters:

Return value:

The error description that is associated with the given error code.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create a new FtpServer instance
...
objFtpServer.Connect "ftpserver1", "account", "pwd"         ' Connect to host ftpserver1
WScript.Echo "LastError: " & objFtpServer.LastError
WScript.Echo "Error description: " & objFtpServer.GetErrorDescription( objFtpServer.LastError )
...

FtpServer.Sleep function

Description:

This function can be used in your script anywhere you want; Suspends the execution of the object for at least the specified interval.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objFtpServer   = CreateObject( "ActiveXperts.FtpServer" )    ' Create Ftperver object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" )  ' Create constants object
...
objFtpServer.Sleep 50

FtpServer.Activate function

Description:

This function activates the ActiveSocket product. A valid registration code is required.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objFtpServer = CreateObject( "ActiveXperts.FtpServer" ) ' Create FtpServer object
objFtpServer.Activate "xyz", True                     ' Substitute xyz by your own registrationkey
                                                      ' Pass True to make the activation persistent, so you need to call
                                                      ' Activate only once. If you pass False, you need to call 
                                                      ' Activate each time the product is started.

10. TftpServer Object

10.1. TftpServer Object - Introduction

The ActiveSocket TftpServer object is based on the Trivial File Transfer Protocol (TFTP) protocol.

TFTP is a forerunner protocol of FTP. The TFTP protocol is basically used for information transfer from a server to a client or vice versa. TFTP is intended to be used when bootstrapping diskless systems are used. This is also used by memory less devices like routers, switches, etc. to get their boot strap information from their servers. TFTP protocol uses UDP for transferring files between server and the client and uses port "69" to transfer, by default. When TFTP is used, the file that is getting transferred is split up into packets each containing 512 bytes of data. The completion of the transfer is informed to the receiver by sending a packet that has 0-511 bytes. The tranfer mode is either ASCII or binary.

The following sample (VBScript) shows how the TftpServer object can be used to download a file from an TFTP server:

    Set objTftpServer = CreateObject ( "ActiveXperts.TftpServer" ) 
 
    objTftpServer.Get "10.1.1.10", "/folder1/file.txt", "c:\\file.txt"  ' Download file, save it locally 
    Wscript.Echo "Get, result: " & objTftpServer.LastError 
    If( objTftpServer.LastError <> 0 ) Then                             ' If download failed then quit
      WScript.Quit
    End If

    WScript.Echo "Packets received: " & objTftpServer.PacketsReceived   ' Print download statistics
    WScript.Echo "Bytes received: "   & objTftpServer.BytesReceived     ' Print download statistics

10.2. TftpServer object - Properties and Functions

Property Type In/Out Mand/Opt Description
Version String Out n/a Version number of ActiveSocket
Build String Out n/a Display build information of ActiveSocket
ExpirationDate String Out n/a Expiration date of ActiveSocket
HostPort Number In/Out O UDP port of the remote TFTP server. Default: 69
BinaryTransfer Boolean In/Out O Specifies how to transfer files: binary (default) or ASCII
LastError Number Out n/a Result of the last called function
LogFile String In/Out O Log file that can be used for troubleshooting purposes

Function Description
Clear Reset all properties to their default values
Get Download a file from a TFTP host
Put Upload a file to a TFTP host
GetErrorDescription Get the description of the given error
Activate Suspends the execution of the object for at least the specified interval

10.3. TftpServer Object - Properties

TftpServer.Version property

Type:

String

Description:

Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objTftpServer    = CreateObject( "ActiveXperts.Tftp" )      ' Create Tftp object
WScript.Echo"Version: " & objTftpServer.Version

TftpServer.Build property

Type:

String

Description:

Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objTftpServer = CreateObject( "ActiveXperts.TftpServer" )     ' Create a new TftpServer object
WScript.Echo  "Build: " & objTftpServer.Build

TftpServer.ExpirationDate property

Type:

String

Description:

Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it. Once you have registered the product, the property holds the empty string ("") value.

Example:

Set objTftpServer = CreateObject( "ActiveXperts.TftpServer" )    ' Create a new TftpServer instance
WScript.Echo "ExpirationDate: " & objTftpServer.ExpirationDate

TftpServer.HostPort property

Type:

Number

Description:

UDP port number to identify a (remote) TFTP server. If you don't specify the 'HostPort' property, port 69 (default TFTP port) is used.

Example:

Set objTftpServer = CreateObject( "ActiveXperts.TftpServer" )    ' Create a new TftpServer instance
...
objTftpServer.HostPort = 8069                                    ' Use port 8069 instead of default port 69
objTftpServer.Get "10.1.1.10", "/file.txt"                       ' Download a file
...

TftpServer.BinaryTransfer property

Type:

Boolean

Description:

Specifies the way files are transfered when downloading (Get) or uploading (Put) files. Default value: True, indicating that files are tranferred in binary mode by default.

Example:

Set objTftpServer = CreateObject( "ActiveXperts.TftpServer" )    ' Create a new TftpServer instance
...
objTftpServer.BinaryMode = False                                 ' Transfer files in ASCII mode when using Get/Put
objTftpServer.Get "10.1.1.10", "/file.txt"                       ' Download a file in ASCII mode

TftpServer.LastError property

Type:

Number

Description:

The result of a previous called function. Use it to check the result of your last function call. A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.

Example:

Set objTftpServer = CreateObject( "ActiveXperts.TftpServer" )    ' Create a new TftpServer instance
...
objTftpServer.Get "10.1.1.10", "/file.txt"                       ' Download a file
WScript.Echo "LastError: " & objTftpServer.LastError
...

TftpServer.LogFile property

Type:

String

Description:

For troubleshooting purposes, you can specify a log file to trace all TFTP operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all TFTP operations will be written to this log file.

Example:

Set objTftpServer = CreateObject( "ActiveXperts.TftpServer" )    ' Create a new TftpServer instance
objTftpServer.LogFile = "C:\Tftp.log"                            ' Write all TFTP operations to the specified log file
...
objTftpServer.Get "10.1.1.10", "/file.txt"                       ' Download a file
...

10.4. TftpServer Object - Functions

TftpServer.Clear function

Description:

Resets all properties to the initial, default values.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objTftpServer = CreateObject( "ActiveXperts.TftpServer" )    ' Create a new TftpServer instance
objTftpServer.Get "10.1.1.10", "/file1.txt"                      ' Download a file
...
objTftpServer.Clear                                              ' Clear properties
objTftpServer.Get "10.1.1.10", "/file2.txt"                      ' Download a file

TftpServer.Get function

Description:

Download a file from the TFTP server.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objTftpServer = CreateObject ( "ActiveXperts.TftpServer" ) 
objTftp.Get "10.1.1.10", "/folder1/file.txt", "c:\\file.txt"     ' Download file, save it to a fixed path 
Wscript.Echo "Get, result: " & objTftp.LastError 
If( objTftp.LastError <> 0 ) Then                                ' If download failed then quit
   WScript.Quit
End If

WScript.Echo "Packets received: " & objTftp.PacketsReceived      ' Print download statistics
WScript.Echo "Bytes received: " & objTftp.BytesReceived          ' Print download statistics

Example:

Set objTftpServer = CreateObject ( "ActiveXperts.TftpServer" ) 

objTftp.Get "10.1.1.10", "/folder1/file.txt"                     ' Download and save file with same name in current dir. 
Wscript.Echo "Get, result: " & objTftp.LastError 
If( objTftp.LastError <> 0 ) Then                                ' If download failed then quit
   WScript.Quit
End If

WScript.Echo "Packets received: " & objTftp.PacketsReceived      ' Print download statistics
WScript.Echo "Bytes received: " & objTftp.BytesReceived          ' Print download statistics

TftpServer.Put function

Description:

Upload a file to the TFTP server.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objTftpServer = CreateObject ( "ActiveXperts.TftpServer" ) 
objTftp.Put "10.1.1.10", "/folder1/file.txt"                     ' Upload and save file with same name in current directory 
Wscript.Echo "Put, result: " & objTftp.LastError 
If( objTftp.LastError <> 0 ) Then                                ' If upload failed then quit
   WScript.Quit
End If

WScript.Echo "Packets sent: " & objTftp.PacketsSent              ' Print upload statistics
WScript.Echo "Bytes sent: " & objTftp.BytesSent                  ' Print upload statistics

TftpServer.GetErrorDescription function

Description:

GetErrorDescription provides the error description of a given error code.

Parameters:

Return value:

The error description that is associated with the given error code.

Example:

Set objTftpServer = CreateObject ( "ActiveXperts.TftpServer" ) 
objTftp.Get "10.1.1.10", "/folder1/file.txt", "c:\\file.txt"     ' Download file, save it to a fixed path 
WScript.Echo "LastError: " & objTftpServer.LastError
WScript.Echo "Error description: " & objTftpServer.GetErrorDescription( objTftpServer.LastError )
...

TftpServer.Activate function

Description:

This function activates the ActiveSocket product. A valid registration code is required.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objTftpServer = CreateObject( "ActiveXperts.Tftp" ) ' Create Tftp object
objTftp.Activate "xyz", True            ' Substitute xyz by your own registrationkey
                                        ' Pass True to make the activation persistent, so you need to call
                                        ' Activate only once. If you pass False, you need to call
                                        ' Activate each time the product is started.

11. DnsServer / DnsRecord Objects

11.1. Introduction

DNS is the Domain Name System. DNS converts machine names to the IP addresses that all machines on the net have. It translates (i.e. 'maps') from name to address and from address to name, and some other things.

The ActiveSocket DNS objects can be used to query servers running a domain name service (DNS) application. It will send domain name query packets to any designated DNS server. There are three data elements required in order to formulate a DNS query using ActiveSocket:

The ActiveSocket DNS objects are useful for gathering address information about hosts in the network. It can be used to query DNS for specific information about hosts, like mail exchanger records [MX], IP address [A], canonical names [CNAME], etc. If you have an IP address, you can get a canonical name back for the address and vice versa. Another useful feature is the ability to get a listing of hosts which serve mail exchange [MX] functions for a specific domain.

The following sample (VBScript) shows how the DnsServer and DnsRecord objects can be used to list all DNS records for a specific domain name:

    
Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")      ' Create object
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Host       = "ns1.interstroom.nl"                   ' DNS server
       
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY  ' Show all DNS records for activexperts.com
WScript.Echo "Lookup, result: " & objDnsServer.LastError    
If( objDnsServer.LastError <> 0 ) Then
    WScript.Quit
End If

If ( objDnsServer.IsAuthoritative = True ) Then
    WScript.Echo "Server is an authority for this domain"
Else
    WScript.Echo "Server is not an authority for this domain"
End If
    
Set objDnsRecord = objDnsServer.GetFirstRecord                   ' Iterate over all DNS records; get first record   	
While ( objDnsServer.LastError = 0 )
    Select Case objDnsRecord.Type 
      Case objConstants.asDNS_TYPE_A
        WScript.Echo "Type             : A"
        WScript.Echo "Name             : " & objDnsRecord.Name
        WScript.Echo "IPv4 Address     : " & objDnsRecord.Address
      Case objConstants.asDNS_TYPE_AAAA
        WScript.Echo "Type             : AAAA"
        WScript.Echo "Name             : " & objDnsRecord.Name
        WScript.Echo "IPv6 Address     : " & objDnsRecord.Address
      Case objConstants.asDNS_TYPE_CNAME
        WScript.Echo "Type             : CNAME"
        WScript.Echo "Name             : " & objDnsRecord.Name
        WScript.Echo "Alias            : " & objDnsRecord.Address
      Case objConstants.asDNS_TYPE_MX 
        WScript.Echo "Type             : MX"
        WScript.Echo "Name             : " & objDnsRecord.Name
        WScript.Echo "Preference       : " & objDnsRecord.Preference
        WScript.Echo "Mail Exchange    : " & objDnsRecord.MailExchange
      Case objConstants.asDNS_TYPE_NS
        WScript.Echo "Type             : NS"
        WScript.Echo "Name             : " & objDnsRecord.Name
        WScript.Echo "Name Server      : " & objDnsRecord.NameServer
      Case objConstants.asDNS_TYPE_PTR
        WScript.Echo "Type             : PTR"
        WScript.Echo "Name             : " & objDnsRecord.Name
        WScript.Echo "Host             : " & objDnsRecord.Address
      Case objConstants.asDNS_TYPE_SOA
        WScript.Echo "Type             : SOA"
        WScript.Echo "Name             : " & objDnsRecord.Name
        WScript.Echo "Name Server      : " & objDnsRecord.NameServer
        WScript.Echo "MailBox          : " & objDnsRecord.MailBox
        WScript.Echo "Serial           : " & objDnsRecord.SerialNumber
        WScript.Echo "Refresh          : " & objDnsRecord.RefreshInterval
        WScript.Echo "Retry Interval   : " & objDnsRecord.RetryInterval
        WScript.Echo "Expiration Limit : " & objDnsRecord.ExpirationLimit
        WScript.Echo "Minimum TTL      : " & objDnsRecord.MinimumTTL
    End Select
  
    WScript.Echo "TTL              : " & objDnsRecord.TTL
    WScript.Echo
    
    Set objDnsRecord = objDnsServer.GetNextRecord                ' Iterate over all DNS records; get next record
Wend

11.2. DnsRecord object - Properties and Functions

Property Type In/Out Mand/Opt Description
Name String Out n/a Name of the record
Type Number Out n/a Type of DNS record
Address String Out n/a IP address (or name of A record in case of CNAME)
TTL Number Out n/a Used as the default TTL for new records created within the zone
MailExchange String Out n/a The email address (replace @ with a dot) of the person responsible for maintenance of the zone
Preference String Out n/a MX preference
NameServer String Out n/a The domain name of the primary DNS server for the zone
MailBox String Out n/a The email address (replace @ with a dot) of the person responsible for maintenance of the zone
SerialNumber String Out n/a Used by secondary DNS servers to check if the zone has changed
RefreshInterval Number Out n/a How often secondary DNS servers should check if changes are made to the zone
RetryInterval Number Out n/a How often secondary DNS server should retry checking if changes are made - if the first refresh fails
ExpirationLimit Number Out n/a How long the zone will be valid after a refresh
MinimumTTL Number Out n/a Used as the default TTL for new records created within the zone

Function Description
Clear Reset all properties to their default values

11.3. DnsRecord Object - Properties

DnsRecord.Name property

Type:

String

Description:

Name of the record.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY  ' Lookup any dns record for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
Set objDnsRecord = objDnsServer.GetFirstRecord                       ' Get first DNS record 
If( objDnsServer.LastError = 0 ) Then
    WScript.Echo "Name: " & objDnsRecord.Name
    WScript.Echo "Type: " & objDnsRecord.Type
    WScript.Echo "Address: " & objDnsRecord.Address
End If

DnsRecord.Type property

Type:

Number

Description:

Type of DNS record. Click here for a list of valid DNS types.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY  ' Lookup any dns record for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
Set objDnsRecord = objDnsServer.GetFirstRecord                       ' Get first DNS record 
If( objDnsServer.LastError = 0 ) Then
    WScript.Echo "Name: " & objDnsRecord.Name
    WScript.Echo "Type: " & objDnsRecord.Type
    WScript.Echo "Address: " & objDnsRecord.Address
End If

DnsRecord.Address property

Type:

String

Description:

IP Address, or name of A record (in case of a CNAME).

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY  ' Lookup any dns record for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
Set objDnsRecord = objDnsServer.GetFirstRecord                       ' Get first DNS record 
If( objDnsServer.LastError = 0 ) Then
    WScript.Echo "Name: " & objDnsRecord.Name
    WScript.Echo "Type: " & objDnsRecord.Type
    WScript.Echo "Address: " & objDnsRecord.Address
End If

DnsRecord.TTL property

Type:

Number

Description:

Used as the default TTL for new records created within the zone.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY  ' Lookup any dns record for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
Set objDnsRecord = objDnsServer.GetFirstRecord                       ' Get first DNS record 
If( objDnsServer.LastError = 0 ) Then
    WScript.Echo "Name: " & objDnsRecord.Name
    WScript.Echo "TTL: " & objDnsRecord.TTL
End If

DnsRecord.MailExchange property

Type:

String

Description:

The A Record for the mail server to connect to its IP-address. The 'MailExchange' property is only set for MX records.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_MX   ' Lookup MX records for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
Set objDnsRecord = objDnsServer.GetFirstRecord                       ' Get first DNS record 
If( objDnsServer.LastError = 0 ) Then
    WScript.Echo "Name: " & objDnsRecord.Name
    WScript.Echo "MailExchange: " & objDnsRecord.MailExchange
    WScript.Echo "Preference: " & objDnsRecord.Preference
End If

DnsRecord.Preference property

Type:

Number

Description:

MX preference. An MX-record has a "Preference" number indicating the order in which the mail server should be used. (Only relevant when multiple MX-records are defined for the same domain name). Mail servers will attempt to deliver mail to the server with the lowest preference number first, and if unsuccessful continue with the next lowest and so on.
THe 'Preference' property is only set for MX records.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_MX   ' Lookup MX records for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
Set objDnsRecord = objDnsServer.GetFirstRecord                       ' Get first DNS record 
If( objDnsServer.LastError = 0 ) Then
    WScript.Echo "Name: " & objDnsRecord.Name
    WScript.Echo "MailExchange: " & objDnsRecord.MailExchange
    WScript.Echo "Preference: " & objDnsRecord.Preference
End If

DnsRecord.NameServer property

Type:

String

Description:

The domain name of the primary DNS server for the zone. Only applies to SOA (Start of Authority) records.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_SOA  ' Lookup SOA record for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
Set objDnsRecord = objDnsServer.GetFirstRecord                       ' Get first DNS record 
If( objDnsServer.LastError = 0 ) Then                                
    WScript.Echo "Name: " & objDnsRecord.Name                        ' Display all SOA record fields 
    WScript.Echo "NameServer: " & objDnsRecord.NameServer
    WScript.Echo "MailBox: " & objDnsRecord.MailBox
    WScript.Echo "NameServer: " & objDnsRecord.NameServer
    WScript.Echo "SerialNumber: " & objDnsRecord.SerialNumber
    WScript.Echo "RefreshInterval: " & objDnsRecord.RefreshInterval
    WScript.Echo "RetryInterval: " & objDnsRecord.RetryInterval
    WScript.Echo "ExpirationLimit: " & objDnsRecord.ExpirationLimit
    WScript.Echo "MinimumTTL: " & objDnsRecord.MinimumTTL
End If

DnsRecord.MailBox property

Type:

String

Description:

The email address (replace @ with a dot) of the person responsible for maintenance of the zone. The standard for this is the "hostmaster" username - such as "hostmaster.activexperts.com" (= hostmaster@activexperts.com). Only applies to SOA (Start of Authority) records.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_SOA  ' Lookup SOA record for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
Set objDnsRecord = objDnsServer.GetFirstRecord                       ' Get first DNS record 
If( objDnsServer.LastError = 0 ) Then                                
    WScript.Echo "Name: " & objDnsRecord.Name                        ' Display all SOA record fields 
    WScript.Echo "NameServer: " & objDnsRecord.NameServer
    WScript.Echo "MailBox: " & objDnsRecord.MailBox
    WScript.Echo "NameServer: " & objDnsRecord.NameServer
    WScript.Echo "SerialNumber: " & objDnsRecord.SerialNumber
    WScript.Echo "RefreshInterval: " & objDnsRecord.RefreshInterval
    WScript.Echo "RetryInterval: " & objDnsRecord.RetryInterval
    WScript.Echo "ExpirationLimit: " & objDnsRecord.ExpirationLimit
    WScript.Echo "MinimumTTL: " & objDnsRecord.MinimumTTL
End If

DnsRecord.SerialNumber property

Type:

String

Description:

Used by secondary DNS servers to check if the zone has changed. If the serial number is higher than what the secondary server has, a zone transfer will be initiated. Only applies to SOA (Start of Authority) records.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_SOA  ' Lookup SOA record for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
Set objDnsRecord = objDnsServer.GetFirstRecord                       ' Get first DNS record 
If( objDnsServer.LastError = 0 ) Then                                
    WScript.Echo "Name: " & objDnsRecord.Name                        ' Display all SOA record fields 
    WScript.Echo "NameServer: " & objDnsRecord.NameServer
    WScript.Echo "MailBox: " & objDnsRecord.MailBox
    WScript.Echo "NameServer: " & objDnsRecord.NameServer
    WScript.Echo "SerialNumber: " & objDnsRecord.SerialNumber
    WScript.Echo "RefreshInterval: " & objDnsRecord.RefreshInterval
    WScript.Echo "RetryInterval: " & objDnsRecord.RetryInterval
    WScript.Echo "ExpirationLimit: " & objDnsRecord.ExpirationLimit
    WScript.Echo "MinimumTTL: " & objDnsRecord.MinimumTTL
End If

DnsRecord.RefreshInterval property

Type:

Number

Description:

How often secondary DNS servers should check if changes are made to the zone. Only applies to SOA (Start of Authority) records.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_SOA  ' Lookup SOA record for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
Set objDnsRecord = objDnsServer.GetFirstRecord                       ' Get first DNS record 
If( objDnsServer.LastError = 0 ) Then                                
    WScript.Echo "Name: " & objDnsRecord.Name                        ' Display all SOA record fields 
    WScript.Echo "NameServer: " & objDnsRecord.NameServer
    WScript.Echo "MailBox: " & objDnsRecord.MailBox
    WScript.Echo "NameServer: " & objDnsRecord.NameServer
    WScript.Echo "SerialNumber: " & objDnsRecord.SerialNumber
    WScript.Echo "RefreshInterval: " & objDnsRecord.RefreshInterval
    WScript.Echo "RetryInterval: " & objDnsRecord.RetryInterval
    WScript.Echo "ExpirationLimit: " & objDnsRecord.ExpirationLimit
    WScript.Echo "MinimumTTL: " & objDnsRecord.MinimumTTL
End If

DnsRecord.RetryInterval property

Type:

Number

Description:

How often secondary DNS server should retry checking if changes are made - if the first refresh fails. Only applies to SOA (Start of Authority) records.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_SOA  ' Lookup SOA record for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
Set objDnsRecord = objDnsServer.GetFirstRecord                       ' Get first DNS record 
If( objDnsServer.LastError = 0 ) Then                                
    WScript.Echo "Name: " & objDnsRecord.Name                        ' Display all SOA record fields 
    WScript.Echo "NameServer: " & objDnsRecord.NameServer
    WScript.Echo "MailBox: " & objDnsRecord.MailBox
    WScript.Echo "NameServer: " & objDnsRecord.NameServer
    WScript.Echo "SerialNumber: " & objDnsRecord.SerialNumber
    WScript.Echo "RefreshInterval: " & objDnsRecord.RefreshInterval
    WScript.Echo "RetryInterval: " & objDnsRecord.RetryInterval
    WScript.Echo "ExpirationLimit: " & objDnsRecord.ExpirationLimit
    WScript.Echo "MinimumTTL: " & objDnsRecord.MinimumTTL
End If

DnsRecord.ExpirationLimit property

Type:

Number

Description:

How long the zone will be valid after a refresh. Secondary servers will discard the zone if no refresh could be made within this interval. Only applies to SOA (Start of Authority) records.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_SOA  ' Lookup SOA record for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
Set objDnsRecord = objDnsServer.GetFirstRecord                       ' Get first DNS record 
If( objDnsServer.LastError = 0 ) Then                                
    WScript.Echo "Name: " & objDnsRecord.Name                        ' Display all SOA record fields 
    WScript.Echo "NameServer: " & objDnsRecord.NameServer
    WScript.Echo "MailBox: " & objDnsRecord.MailBox
    WScript.Echo "NameServer: " & objDnsRecord.NameServer
    WScript.Echo "SerialNumber: " & objDnsRecord.SerialNumber
    WScript.Echo "RefreshInterval: " & objDnsRecord.RefreshInterval
    WScript.Echo "RetryInterval: " & objDnsRecord.RetryInterval
    WScript.Echo "ExpirationLimit: " & objDnsRecord.ExpirationLimit
    WScript.Echo "MinimumTTL: " & objDnsRecord.MinimumTTL
End If

DnsRecord.MinimumTTL property

Type:

Number

Description:

Minimum (default) TTL. Only applies to SOA (Start of Authority) records.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_SOA  ' Lookup SOA record for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
Set objDnsRecord = objDnsServer.GetFirstRecord                       ' Get first DNS record 
If( objDnsServer.LastError = 0 ) Then                                
    WScript.Echo "Name: " & objDnsRecord.Name                        ' Display all SOA record fields 
    WScript.Echo "NameServer: " & objDnsRecord.NameServer
    WScript.Echo "MailBox: " & objDnsRecord.MailBox
    WScript.Echo "NameServer: " & objDnsRecord.NameServer
    WScript.Echo "SerialNumber: " & objDnsRecord.SerialNumber
    WScript.Echo "RefreshInterval: " & objDnsRecord.RefreshInterval
    WScript.Echo "RetryInterval: " & objDnsRecord.RetryInterval
    WScript.Echo "ExpirationLimit: " & objDnsRecord.ExpirationLimit
    WScript.Echo "MinimumTTL: " & objDnsRecord.MinimumTTL
End If

11.4. DnsRecord Object - Functions

DnsRecord.Clear function

Description:

Resets all properties to the initial, default values.

Parameters:

Return value:

Always 0.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY  ' Lookup any record for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
Set objDnsRecord = objDnsServer.GetFirstRecord                       ' Get first DNS record 
While( objDnsServer.LastError = 0 ) Then                                
    WScript.Echo "Name: " & objDnsRecord.Name                       
    objDnsRecord.Clear()                                             ' Clear DNS record 
    Set objDnsRecord = objDnsServer.GetNextRecord                    ' Get next DNS record 
WEnd

11.5. DnsServer object - Properties and Functions

Property Type In/Out Mand/Opt Description
Version String Out n/a Version number of ActiveSocket
Build String Out n/a Display build information of ActiveSocket
ExpirationDate String Out n/a Expiration date of ActiveSocket
Server String In/Out O Remote DNS Server's host name or IP address
ServerPort Number In/Out O DNS Server port. Default: 53
LastError Number Out n/a Result of the last called function
LogFile String In/Out O Log file that can be used for troubleshooting purposes

Function Description
Clear Reset all properties to their default values
Lookup Lookup DNS record(s)
GetFirstRecord Get first DNS record
GetNextRecord Get next DNS record
IsAuthoritative Set to True if DNS server is authoritative
GetErrorDescription Get the description of the given error
Sleep Suspends the execution of the object for at least the specified interval
Activate Activate Software

11.6. DnsServer Object - Properties

DnsServer.Version property

Type:

String

Description:

Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objDnsServer = CreateObject("ActiveXperts.DnsServer")       ' Create a new DnsServer instance
WScript.Echo  "Version: " & objDnsServer.Version

DnsServer.Build property

Type:

String

Description:

Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objDnsServer = CreateObject( "ActiveXperts.DnsServer" )     ' Create a new DnsServer object
WScript.Echo  "Build: " & objDnsServer.Build

DnsServer.ExpirationDate property

Type:

String

Description:

Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.

Example:

Set objDnsServer = CreateObject( "ActiveXperts.DnsServer" )     ' Create a new DnsServer instance
WScript.Echo "ExpirationDate: " & objDnsServer.ExpirationDate

DnsServer.Server property

Type:

String

Description:

Host name or IP address of the DNS server.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server      = "ns1.xyz.intra"                           ' Remote DNS server: ns1.xyz.intra    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY  ' Lookup any record for activexperts.com    
...

DnsServer.ServerPort property

Type:

Number

Description:

TCP port number to identify a (remote) DNS server. If you don't specify the 'ServerPort' property, port 53 (default DNS port) is used.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server      = "ns1.xyz.intra"                           ' Remote DNS server: ns1.xyz.intra    
objDnsServer.ServerPort  = 8053                                      ' Use alternate port: 8053    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY  ' Lookup any record for activexperts.com    
...

DnsServer.LastError property

Type:

Number

Description:

The result of a previous called function. Use it to check the result of your last function call. A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY  ' Lookup any record for activexperts.com    
WScript.Echo "Lookup, result: " & objDnsServer.LastError             ' Show result

DnsServer.LogFile property

Type:

String

Description:

For troubleshooting purposes, you can specify a log file to trace all DNS operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all DNS operations will be written to this log file.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.LogFile = "c:\dns.log"                                  ' Set log file    
objDnsServer.Server  = "ns1.interstroom.nl"                          
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY  
... 

11.7. DnsServer Object - Functions

DnsServer.Clear function

Description:

Resets all properties to the initial, default values.

Parameters:

Return value:

Always 0.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server      = "ns1.xyz.intra"                           ' Remote DNS server: ns1.xyz.intra    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY  ' Lookup any record for activexperts.com    
...
objDnsServer.Clear                                                   ' Reset all properties  
objDnsServer.Server      = "ns1.interstroom.nl"                      ' Remote DNS server: ns1.xyz.intra    
...

DnsServer.Lookup function

Description:

Lookup DNS record(s).

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY  ' Lookup any dns record for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
Set objDnsRecord = objDnsServer.GetFirstRecord                       ' Get first DNS record 
...

DnsServer.GetFirstRecord,
DnsServer GetNextRecord function

Description:

Iterate over all DSN records that were a result of the Lookup query.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY  ' Lookup any dns record for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
Set objDnsRecord = objDnsServer.GetFirstRecord                       ' Get first DNS record 
While( objDnsServer.LastError = 0 )
    WScript.Echo "Name: " & objDnsRecord.Name
    ...
    Set objDnsRecord = objDnsServer.GetNextRecord                    ' Get next DNS record 
WEnd

DnsServer.IsAuthoritative function

Description:

Indicates if DNS server is authoritative for the queried domain.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                          ' Apply queries to DNS server ns1.interstroom.nl    
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY  ' Lookup any dns record for activexperts.com    
If( objDnsServer.LastError = 0 ) Then
    WScript.Quit
End If
WScript.Echo "IsAuthoritative: " & objDnsServer.IsAuthoritative()    ' Is authoritative ?

DnsServer.GetErrorDescription function

Description:

GetErrorDescription provides the error description of a given error code.

Parameters:

Return value:

The error description that is associated with the given error code.

Example:

Set objDnsServer = CreateObject ( "ActiveXperts.DnsServer")          ' Create a new DnsServer instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objDnsServer.Server  = "ns1.interstroom.nl"                            
objDnsServer.Lookup "activexperts.com", objConstants.asDNS_TYPE_ANY   
WScript.Echo "LastError: " & objDnsServer.LastError
WScript.Echo "Error description: " & objDnsServer.GetErrorDescription( objDnsServer.LastError )
...

DnsServer.Sleep function

Description:

This function can be used in your script anywhere you want; Suspends the execution of the object for at least the specified interval.

Parameters:

Return value:

Always 0.

Example:

Set objDnsServer   = CreateObject( "ActiveXperts.DnsServer" )    ' Create DnsServer object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" )  ' Create constants object
...
objDnsServer.Sleep 500

DnsServer.Activate function

Description:

This function activates the ActiveSocket product. A valid registration code is required.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objDnsServer = CreateObject( "ActiveXperts.DnsServer" ) ' Create DnsServer object
objDnsServer.Activate "xyz", True       ' Substitute xyz by your own registrationkey
                                        ' Pass True to make the activation persistent, so you need to call
                                        ' Activate only once. If you pass False, you need to call 
                                        ' Activate each time the product is started.

12. Ssh Object

12.1. Ssh Object - Introduction

SSH Secure Shell allows secure network services over an insecure network, such as the Internet.

The Secure Shell concept originated on UNIX as a replacement for the insecure "Berkeley services", that is, the rsh , rcp, and rlogin commands. SSH Secure Shell replaces other, insecure terminal applications (such as Telnet and FTP). It allows you to securely login to remote host computers, to execute commands safely in a remote computer, to securely copy remote files, to forward X11 sessions (on UNIX), and to provide secure encrypted and authenticated communications between two non-trusted hosts. Also arbitrary TCP/IP ports can be forwarded over the secure channel, enabling secure connection, for example, to an email service.

SSH Secure Shell with its array of unmatched security features is an essential tool in today's network environment. It is a powerful guardian against the numerous security hazards that nowadays threaten network communications.

The ActiveSocket Ssh implementation is based on the PuTTY implementation. With the ActiveSocket Ssh object, you can login onto a remote machine running the SSH daemon, and execute a command or shell script. It has no user interface by itself: standard error and standard output are not copied to the console, but are copied to the corresponding object properties (StdErr and StdOut) instead.

There are two ways to authenticate: by using a password or by using a 'private key'. When using a password to authenticate it is required that the host private key is known to the system. If the hosts private key is unknown to the system or if it was changed since the last connection the Ssh object will return an error. To connect anyway and store the host key in the registry for future connections the 'AcceptHostKey' property can be set.

NOTES:

The following sample (in VBScript) runs the '/bin/ls' command on host '192.168.1.10' by logging in using a password:

Set objSsh           = CreateObject("ActiveXperts.Ssh")    ' Create an Ssh instance
objSsh.Host          = "192.168.1.10"                      ' Hostname or IP address of remote UNIX/LINUX machine
objSsh.UserName      = "root"                              ' Login as 'root'
objSsh.Password      = "topsecret"                         ' Use a password to login
objSsh.Command       = "/bin/ls"                           ' Command to execute
objSsh.ScriptTimeOut = 5000                                ' Time-out (in milliseconds)
objSsh.Run                                                 ' Execute the command now
WScript.Echo "Run: result = " & objSsh.LastError 
If objSsh.LastError <> 0 Then
  WScript.Echo "Error "  & objSsh.LastError
End If
' YES, command has completed
WScript.Echo "StdErr: " & objSsh.StdErr                    ' Print Standard Output
WScript.Echo "StdOut: " & objSsh.StdOut                    ' Print Standard Error

WScript.Echo "Ready."

The following sample (in VBScript) runs the '/bin/ls' command on host '192.168.1.10' by using a private key file:

Set objSsh           = CreateObject("ActiveXperts.Ssh")    ' Create an Ssh instance
objSsh.Host          = "192.168.1.10"                      ' Hostname or IP address of remote UNIX/LINUX machine
objSsh.UserName      = "root"                              ' Login as 'root'
objSsh.PrivateKeyFile = "c:\files\privkey.ppk"             ' Use a private key file to login
objSsh.Command       = "/bin/ls"                           ' Command to execute
objSsh.ScriptTimeOut = 5000                                ' Time-out (in milliseconds)
objSsh.Run                                                 ' Execute the command now
WScript.Echo "Run: result = " & objSsh.LastError 
If objSsh.LastError <> 0 Then
  WScript.Echo "Error "  & objSsh.LastError
Else
  ' YES, command has completed
  WScript.Echo "StdErr: " & objSsh.StdErr                  ' Print Standard Output
  WScript.Echo "StdOut: " & objSsh.StdOut                  ' Print Standard Error
End If
WScript.Echo "Ready."

12.2. Ssh object - Properties and Functions Overview

Property Type In/Out Mand/Opt Description
Version String Out n/a Version number of ActiveSocket
Build String Out n/a Display build information of ActiveSocket
ExpirationDate String Out n/a Expiration date of ActiveSocket
LastError Number Out n/a Result of the last called function
Host String In/Out M Specifies the host on which to run the command
Port Number In/Out O TCP port number to identify a (remote) SSH daemon. Default: 22
UserName String In/Out M Specifies the user name to use on the remote host
Password String In/Out O Specifies the password to use on the remote host
PrivateKeyFile String In/Out O Specifies the private key file to logon to the remote host.
Command String In/Out M Specifies the command to run on the remote host
ScriptTimeOut Number In/Out O Specifies the number of milliseconds before the command will times out
AcceptHostKey Boolean In/Out O Specifies whether to accept an unknown or changed host key
HostFingerprint String Out n/a The Ssh 'Run' function copies the host key fingerprint to this property
StdErr String Out n/a The Ssh 'Run' function copies its standard error to this property
StdOut String Out n/a The Ssh 'Run' function copies its standard output to this property

Function Description
Clear Reset all properties to the default values
Run Run the command on the remote host
GetErrorDescription Get the description of the given error
Sleep Suspends the execution of the object for at least the specified interval
Activate Activate Software

12.3. Ssh Object - Properties

Ssh.Version property

Type:

String

Description:

Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objSsh = CreateObject( "ActiveXperts.Ssh" )            ' Create Ssh object
WScript.Echo  "Version: " & objSsh.Version

Ssh.Build property

Type:

String

Description:

Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objSsh = CreateObject( "ActiveXperts.Ssh" )           ' Create Ssh object
WScript.Echo  "Build: " & objSsh.Build

Ssh.ExpirationDate property

Type:

String

Description:

Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.

Example:

Set objSsh = CreateObject( "ActiveXperts.Ssh" )            ' Create Ssh object
WScript.Echo "ExpirationDate: " & objSsh.ExpirationDate

Ssh.LastError property

Type:

Number

Description:

The result of a previous called function. Use it to check the result of your last function call. A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.

Example:

Set objSsh           = CreateObject("ActiveXperts.Ssh")    ' Create an Ssh instance
...
objSsh.Run
WScript.Echo "LastError: " & objSsh.LastError

Ssh.Host property

Type:

String

Description:

Specifies the host on which to run the command.

Example:

Set objSsh           = CreateObject("ActiveXperts.Ssh")    ' Create an Ssh instance
objSsh.Host          = "server01.domain.dom"
...
objSsh.Command       = "/bin/ls"
objSsh.Run

Ssh.Port property

Type:

Number

Description:

TCP port number to identify a remote SSH daemon. If you don't specify the 'Port' property, port 22 (default SSH port) is used.

Example:

Set objSsh           = CreateObject("ActiveXperts.Ssh")    ' Create an Ssh instance
objSsh.Host          = "server01.domain.dom"
objSsh.Port          = 8022                                ' Use port 8022 instead of 22
...
objSsh.Command       = "/bin/ls"
objSsh.Run

Ssh.UserName property

Type:

String

Description:

Specifies the user name to use on the remote host. You must also specify either a Password or Private Key to logon to the machine.

Example:

Set objSsh           = CreateObject("ActiveXperts.Ssh")    ' Create an Ssh instance
objSsh.Host          = "server01.domain.dom"
objSsh.UserName      = "mjohnson"
objSsh.Password      = "topsecret"
objSsh.Command       = "/bin/ls"
objSsh.Run

Ssh.Password property

Type:

String

Description:

Specifies the password to use on the remote host. If you do not use a password, you must use a Private Key to logon to the machine.

Example:

Set objSsh           = CreateObject("ActiveXperts.Ssh")    ' Create an Ssh instance
objSsh.Host          = "server01.domain.dom"
objSsh.UserName      = "mjohnson"
objSsh.Password      = "topsecret"
objSsh.Command       = "/bin/ls"
objSsh.Run

Ssh.PrivateKeyFile property

Type:

String

Description:

Specifies the private key file to use on the remote host. If you do not use a private key, you must use a Password to logon to the machine.

Example:

Set objSsh           = CreateObject("ActiveXperts.Ssh")    ' Create an Ssh instance
objSsh.Host          = "server01.domain.dom"
objSsh.UserName      = "mjohnson"
objSsh.PrivateKeyFile= "c:\keys\root.ppk"
objSsh.Command       = "/bin/ls"
objSsh.Run

Ssh.Command property

Type:

String

Description:

Specifies the command to run on the remote host.

Example:

Set objSsh           = CreateObject("ActiveXperts.Ssh")    ' Create an Ssh instance
objSsh.Command       = "/bin/ls"
objSsh.Host          = "server01.domain.dom"
objSsh.UserName      = "mjohnson"
objSsh.Password      = "topsecret"
objSsh.Run

Ssh.ScriptTimeOut property

Type:

Number

Description:

Specifies the number of milliseconds before the command will time out.

Example:

Set objSsh           = CreateObject("ActiveXperts.Ssh")    ' Create an Ssh instance
objSsh.Host          = "server01.domain.dom"
objSsh.UserName      = "mjohnson"
objSsh.Password      = "topsecret"
objSsh.Command       = "/bin/ls"
objSsh.ScriptTimeOut = 6000                                ' Timeout after 6000 milliseconds
objSsh.Run

Ssh.AcceptHostKey property

Type:

Boolean

Description:

Specifies whether to accept an unknown or changed host key and add it to the registry. Leaving this property set to true when connecting to unknown or untrusted hosts poses a security risk.

Example:

Set objSsh           = CreateObject("ActiveXperts.Ssh")    ' Create an Ssh instance
...
objSsh.AcceptHostKey = true
objSsh.Run

Ssh.HostFingerprint property

Type:

String

Description:

The Ssh 'Run' function copies the host key fingerprint to this property

Example:

Set objSsh           = CreateObject("ActiveXperts.Ssh")    ' Create an Ssh instance
...
objSsh.Run
WScript.Echo "Host key fingerprint: " & objSsh.HostFingerprint

Ssh.StdErr property

Type:

String

Description:

Ssh connects to the host and executes the command. Ssh copies its standard error of the remote command to the 'StdErr' property.

Example:

Set objSsh           = CreateObject("ActiveXperts.Ssh")    ' Create an Ssh instance
...
objSsh.Run
If( objSsh.LastError = 0 ) Then
  WScript.Echo "StdErr: " & objSsh.StdErr
End

Ssh.StdOut property

Type:

String

Description:

Ssh connects to the host and executes the command. Ssh copies its standard out of the remote command to the 'StdOut' property.

Example:

Set objSsh           = CreateObject("ActiveXperts.Ssh")    ' Create an Ssh instance
objSsh.Run
If( objSsh.LastError = 0 ) Then
  WScript.Echo "StdOut: " & objSsh.StdOut
End

12.4. Ssh Object - Functions

Ssh.Clear function

Description:

Reset all properties to the initial values. Use this function when you make consecutive calls to the Run function. It resets all properties

Parameters:

Return value:

Always 0.

Example:

Set objSsh = CreateObject("ActiveXperts.Ssh")              ' Create an Ssh instance
...
objSsh.Run
objSsh.Clear                                               ' Resets properties
' Set new property values
...
objSsh.Run
objSsh.Clear
...

Ssh.Run function

Description:

Run the command on the remote host.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objSsh           = CreateObject("ActiveXperts.Ssh")  ' Create an Ssh instance
objSsh.Host          = "192.168.1.10"
objSsh.UserName      = "mjohnson"
objSsh.Password      = "topsecret"
objSsh.Command       = "/bin/ls"
objSsh.Run
WScript.Echo "Run: result = " & objSsh.LastError

Ssh.GetErrorDescription function

Description:

GetErrorDescription provides the error description of a given error code.

Parameters:

Return value:

The error description that is associated with the given error code.

Example:

Set objSsh           = CreateObject("ActiveXperts.Ssh")  ' Create an Ssh instance
objSsh.Host          = "192.168.1.10"
objSsh.UserName      = "mjohnson"
objSsh.Password      = "topsecret"
objSsh.Command       = "/bin/ls"
objSsh.Run
WScript.Echo "Error description: " & objSsh.GetErrorDescription( objSsh.LastError )

Ssh.Sleep function

Description:

This function can be used in your script anywhere you want. Suspends the execution of the object for at least the specified interval.

Parameters:

Return value:

Always 0.

Example:

Set objSsh         = CreateObject( "ActiveXperts.Ssh" )          ' Create Ssh object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" )  ' Create constants object
...
objSsh.Sleep 500

Ssh.Activate function

Description:

This function activates the ActiveSocket product. A valid registration code is required.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objSsh         = CreateObject( "ActiveXperts.Ssh" )       ' Create Ssh object
objSsh.Activate "xyz", True                  ' Substitute xyz by your own registrationkey
                                             ' Pass True to make the activation persistent, so you need to call
                                             ' Activate only once. If you pass False, you need to call
                                             ' Activate each time the product is started

13. Rsh Object

13.1. Rsh Object - Introduction

Rsh executes a command on a host. The remote hosts must run the Rsh daemon.
An Rsh client utility is shipped with most operating systems these days. This Rsh command line utility copies its standard input to the remote command, the standard output of the remote command to its standard output, and the standard error of the remote command to its standard error. Interrupt, quit and terminate signals are propagated to the remote command; rsh normally terminates when the remote command does.

The ActiveSocket Rsh object has the same functionality as the Rsh command-line utility, except that it has no user interface by itself: standard error and standard output are not copied to the console, but are copied to the corresponding object properties (StdErr and StdOut) instead.

The following sample (in VBScript) runs the '/bin/ls' command on host '192.168.1.10', and will timeout when the script takes more than 5000 milliseconds:

Set objRsh           = CreateObject("ActiveXperts.Rsh")    ' Create an Rsh instance
objRsh.Host          = "192.168.1.10"                      ' Hostname or IP address of remote UNIX/LINUX machine
objRsh.UserName      = "root"                              ' Login as 'root'
objRsh.Password      = "topsecret"                         ' Use a password to login
objRsh.Command       = "/bin/ls"                           ' Command to execute
objRsh.ScriptTimeOut = 5000                                ' Time-out (in milliseconds)
objRsh.Run                                                 ' Execute the command now
WScript.Echo "Run: result = " & objRsh.LastError 
If objRsh.LastError <> 0 Then
  WScript.Echo "Error "  & objRsh.LastError
End If
' YES, command has completed
WScript.Echo "StdErr: " & objRsh.StdErr                    ' Print Standard Output
WScript.Echo "StdOut: " & objRsh.StdOut                    ' Print Standard Error

WScript.Echo "Ready."

13.2. Rsh object - Properties and Functions Overview

Property Type In/Out Mand/Opt Description
Version String Out n/a Version number of ActiveSocket
Build String Out n/a Display build information of ActiveSocket
ExpirationDate String Out n/a Expiration date of ActiveSocket
LastError Number Out n/a Result of the last called function
Command String In/Out M Specifies the command to run on the remote host
Host String In/Out M Specifies the host on which to run the command
UserName String In/Out M Specifies the user name to use on the remote host. If omitted, the logged on user name is used.
ScriptTimeOut Number In/Out O Specifies the number of milliseconds until the command times out
StdErr String Out n/a The Rsh 'Run' function copies its standard error to this property
StdOut String Out n/a The Rsh 'Run' function copies its standard output to this property

Function Description
Clear Reset all properties to the default values
Run Run the command on the remote host
GetErrorDescription Get the description of the given error
Sleep Suspends the execution of the object for at least the specified interval
Activate Activate Software

13.3. Rsh Object - Properties

Rsh.Version property

Type:

String

Description:

Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objRsh = CreateObject( "ActiveXperts.Rsh" )            ' Create Rsh object
WScript.Echo  "Version: " & objRsh.Version

Rsh.Build property

Type:

String

Description:

Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objRsh = CreateObject( "ActiveXperts.Rsh" )           ' Create Rsh object
WScript.Echo  "Build: " & objRsh.Build

Rsh.ExpirationDate property

Type:

String

Description:

Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.

Example:

Set objRsh = CreateObject( "ActiveXperts.Rsh" )            ' Create Rsh object
WScript.Echo "ExpirationDate: " & objRsh.ExpirationDate

Rsh.LastError property

Type:

Number

Description:

The result of a previous called function. Use it to check the result of your last function call. A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.

Example:

Set objRsh           = CreateObject("ActiveXperts.Rsh")    ' Create an Rsh instance
...
objRsh.Run
WScript.Echo "LastError: " & objRsh.LastError

Rsh.Command property

Type:

String

Description:

Specifies the command to run on the remote host.

Example:

Set objRsh           = CreateObject("ActiveXperts.Rsh")    ' Create an Rsh instance
objRsh.Command       = "/bin/ls"
objRsh.Host          = "server01.domain.dom"
objRsh.Run

Rsh.UserName property

Type:

String

Description:

Specifies the user name to use on the remote host. If omitted, the logged on user name is used.

Example:

Set objRsh           = CreateObject("ActiveXperts.Rsh")    ' Create an Rsh instance
objRsh.Host          = "server01.domain.dom"
objRsh.Command       = "/bin/ls"
objRsh.UserName      = "mjohnson"
objRsh.Run

Rsh.Host property

Type:

String

Description:

Specifies the host on which to run the command.

Example:

Set objRsh           = CreateObject("ActiveXperts.Rsh")    ' Create an Rsh instance
objRsh.Host          = "server01.domain.dom"
objRsh.Command       = "/bin/ls"
objRsh.Run

Rsh.ScriptTimeOut property

Type:

Number

Description:

Specifies the number of milliseconds before the command will time out.

Example:

Set objRsh           = CreateObject("ActiveXperts.Rsh")    ' Create an Rsh instance
objRsh.Host          = "server01.domain.dom"
objRsh.Command       = "/bin/ls"
objRsh.ScriptTimeOut = 6000                                ' Timeout after 6000 milliseconds
objRsh.Run

Rsh.StdErr property

Type:

String

Description:

Rsh connects to the host and executes the command. Rsh copies its standard error of the remote command to the 'StdErr' property.

Example:

Set objRsh           = CreateObject("ActiveXperts.Rsh")    ' Create an Rsh instance
...
objRsh.Run
If( objRsh.LastError = 0 ) Then
  WScript.Echo "StdErr: " & objRsh.StdErr
End

Rsh.StdOut property

Type:

String

Description:

Rsh connects to the host and executes the command. Rsh copies its standard out of the remote command to the 'StdOut' property.

Example:

Set objRsh           = CreateObject("ActiveXperts.Rsh")    ' Create an Rsh instance
objRsh.Run
If( objRsh.LastError = 0 ) Then
  WScript.Echo "StdOut: " & objRsh.StdOut
End

13.4. Rsh Object - Functions

Rsh.Clear function

Description:

Reset all properties to the initial values. Use this function when you make consecutive calls to the Run function. It resets all properties

Parameters:

Return value:

Always 0.

Example:

Set objRsh = CreateObject("ActiveXperts.Rsh")              ' Create an Rsh instance
...
objRsh.Run
objRsh.Clear                                               ' Resets properties
' Set new property values
...
objRsh.Run
objRsh.Clear
...

Rsh.Run function

Description:

Run the command on the remote host.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objRsh           = CreateObject("ActiveXperts.Rsh")  ' Create an Rsh instance
objRsh.Host          = "192.168.1.10"
objRsh.Command       = "/bin/ls"
objRsh.Run
WScript.Echo "Run: result = " & objRsh.LastError 

Rsh.GetErrorDescription function

Description:

GetErrorDescription provides the error description of a given error code.

Parameters:

Return value:

The error description that is associated with the given error code.

Example:

Set objRsh           = CreateObject("ActiveXperts.Rsh")  ' Create an Rsh instance
objRsh.Host          = "192.168.1.10"
objRsh.Command       = "/bin/ls"
objRsh.Run
WScript.Echo "Run: result = " & objRsh.LastError 

Rsh.Sleep function

Description:

This function can be used in your script anywhere you want. Suspends the execution of the object for at least the specified interval.

Parameters:

Return value:

Always 0.

Example:

Set objRsh         = CreateObject( "ActiveXperts.Rsh" )          ' Create Rsh object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" )  ' Create constants object
...
objRsh.Sleep 500

Rsh.Activate function

Description:

This function activates the ActiveSocket product. A valid registration code is required.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objRsh         = CreateObject( "ActiveXperts.Rsh" )       ' Create Rsh object
objRsh.Activate "xyz", True                  ' Substitute xyz by your own registrationkey
                                             ' Pass True to make the activation persistent, so you need to call
                                             ' Activate only once. If you pass False, you need to call
                                             ' Activate each time the product is started

14. Ntp Object

14.1. Ntp Object - Introduction

The Network Time Protocol (NTP) has been developed to address the issue of providing accurate and synchronized time across the Internet. The protocol itself has been in development since 1985 and has therefore reached a fairly mature status. The latest stable version of NTP is version 3 and described in RFC-1305 the latest testing version is NTP version 4.

The Network Time Protocol aims to synchronize a systems clock to Coordinated Universal Time (UTC). UTC is a development of Greenwich Mean Time (GMT). GMT is based on the rotation of the earth while UTC is based on the standard length of a second determined from quantum phenomena, but both use the Greenwich time zone as the zero offset.

NTP uses a augmented hierarchical client-server topology. A small number of servers distribute time to a larger number of clients which can simultaneously act as servers to further clients. The top level clients are referred to as stratum 1 servers and their clients are termed as being at stratum 2. Clients of a stratum 2 server are at stratum 3 and so on. The stratum 1 servers are synchronized to radio clocks which receive time signals from national time standards such as the MSF signal provided by the NPL broadcast from Rugby or the GPS time signal provided by the Global Positioning System. The radio clocks themselves are termed stratum 0 servers.

The ActiveSocket Ntp object enables you to add Ntp functionality to your program. Here is a small example (in VBScript) to show how to use the Ntp object: The following sample (in VBScript) runs the '/bin/ls' command on host '192.168.1.10', and will timeout when the script takes more than 5000 milliseconds:

objNtp = CreateObject( "ActiveXperts.Ntp" )    ' Create a new Ntp instance
objNtp.GetTime "mytimeserver.domain.dom"       ' Retrieve time from this time server
If( objNtp.LastError = 0 ) Then
  WScript.Echo "Time retrieved successfully, the results are:"
  WScript.Echo "Year : "   & objNtp.Year
  WScript.Echo "Month : "  & objNtp.Month
  WScript.Echo "Day : "    & objNtp.Day
  WScript.Echo "Hour : "   & objNtp.Hour
  WScript.Echo "Minute : " & objNtp.Minute
  WScript.Echo "Second : " & objNtp.Second
End If

14.2. Ntp object - Properties and Functions Overview

Property Type In/Out Mand/Opt Description
Version String Out n/a Version number of ActiveSocket
Build String Out n/a Display build information of ActiveSocket
ExpirationDate String Out n/a Expiration date of ActiveSocket
LastError Number Out n/a Result of the last called function
Year Number Out n/a The year, as provided by the NTP server
Month Number Out n/a The month, as provided by the NTP server
Day Number Out n/a The day, as provided by the NTP server
Hour Number Out n/a The hour, as provided by the NTP server
Minute Number Out n/a The minute, as provided by the NTP server
Second Number Out n/a The second, as provided by the NTP server
LocalOffsetSeconds Number Out n/a The offset (in seconds) between the local computer and the Network Time Server

Function Description
Clear Reset all properties to the default values
GetTime Query the NTP server to retrieve date and time
GetErrorDescription Get the description of the given error
Sleep Suspends the execution of the object for at least the specified interval
Activate Activate Software

14.3. Ntp Object - Properties

Ntp.Version property

Type:

String

Description:

Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objNtp = CreateObject( "ActiveXperts.Ntp" )            ' Create Ntp object
WScript.Echo  "Version: " & objNtp.Version

Ntp.Build property

Type:

String

Description:

Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objNtp = CreateObject( "ActiveXperts.Ntp" )           ' Create Ntp object
WScript.Echo  "Build: " & objNtp.Build

Ntp.ExpirationDate property

Type:

String

Description:

Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.

Example:

Set objNtp = CreateObject( "ActiveXperts.Ntp" )            ' Create Ntp object
WScript.Echo "ExpirationDate: " & objNtp.ExpirationDate

Ntp.LastError property

Type:

Number

Description:

The result of a previous called function. Use it to check the result of your last function call. A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.

Example:

objNtp = CreateObject( "ActiveXperts.Ntp" )                ' Create a new Ntp instance
objNtp.GetTime "timeserver01.domain.dom"                   ' Retrieve time
WScript.Echo "LastError: " & objNtp.LastError

Ntp.Year,
Ntp.Month,
Ntp.Day,
Ntp.Hour,
Ntp.Minute,
Ntp.Second properties

Type:

Number

Description:

After a successful call to the GetTime function, the 'Year', 'Month', 'Day', 'Hour', 'Minute' and 'Second' properties are assigned with the time information that was retrieved from the Network Time Server. The properties are read-only; you cannot assign a value to it.

Example:

objNtp = CreateObject( "ActiveXperts.Ntp" )                ' Create a new Ntp instance
objNtp.GetTime( "timeserver.domain.dom" )                  ' Retrieve time
if( objNtp.LastError = 0 ) Then
  WScript.Echo "Year : " & objNtp.Year
  WScript.Echo "Month : " & objNtp.Month
  WScript.Echo "Day : " & objNtp.Day
  WScript.Echo "Hour : " & objNtp.Hour
  WScript.Echo "Minute : " & objNtp.Minute
  WScript.Echo "Second : " & objNtp.Second
End If

Ntp.LocalOffsetSeconds property

Type:

Number

Description:

After a successful call to the GetTime function, the 'LocalOffsetSeconds' holds the offset (in seconds) between the NTP server time and the local computer time. Use this value to check if your local computer time is in sync with the NTP server's time. The property is read-only; you cannot assign a value to it.

Example:

objNtp = CreateObject( "ActiveXperts.Ntp" )                ' Create a new Ntp instance
objNtp.GetTime( "timeserver.domain.dom" )                  ' Retrieve time
If( objNtp.LastError = 0 ) Then
  WScript.Echo "Time offset : " & objNtp.LocalOffsetSeconds & " seconds"
End If

14.4. Ntp Object - Functions

Ntp.Clear function

Description:

Resets all properties to the initial values. Use this function when you make consecutive calls to the GetTime function. It sets LastError and Year, Month, Day, Hour, Minute and Second to 0.

Parameters:

Return value:

Always 0.

Example:

objNtp = CreateObject( "ActiveXperts.Ntp" )                ' Create a new Ntp instance
objNtp.GetTime( "timeserver.domain.dom" )                  ' Retrieve time
...
objNtp.Clear()
objNtp.GetTime( "timeserver02.domain.dom" )
...
objNtp.Clear()
objNtp.GetTime( "timeserver03.domain.dom" )
...

Ntp.GetTime function

Description:

Query the network time server and retrieve its date and time.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

objNtp = CreateObject( "ActiveXperts.Ntp" )                ' Create a new Ntp instance
objNtp.GetTime( "timeserver.domain.dom" )                  ' Retrieve time
If( objNtp.LastError = 0 ) Then
  WScript.Echo "Year : "   & objNtp.Year
  WScript.Echo "Month : "  & objNtp.Month
  WScript.Echo "Day : "    & objNtp.Day
  WScript.Echo "Hour : "   & objNtp.Hour
  WScript.Echo "Minute : " & objNtp.Minute
  WScript.Echo "Second : " & objNtp.Second
End If

Ntp.GetErrorDescription function

Description:

GetErrorDescription provides the error description of a given error code.

Parameters:

Return value:

The error description that is associated with the given error code.

Example:

Set objNtp = CreateObject("ActiveXperts.Ntp")              ' Create a new Ntp instance
objNtp.GetTime( "invalidtimeserver.com" )                  ' Retrieve time
WScript.Echo "Error description: " & objNtp.GetErrorDescription( objNtp.LastError )

Ntp.Sleep function

Description:

This function can be used in your script anywhere you want. Suspends the execution of the object for at least the specified interval.

Parameters:

Return value:

Always 0.

Example:

Set objNtp         = CreateObject( "ActiveXperts.Ntp" )          ' Create Ntp object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" )  ' Create constants object
...
objNtp.Sleep 500

Ntp.Activate function

Description:

This function activates the ActiveSocket product. A valid registration code is required.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objNtp         = CreateObject( "ActiveXperts.Ntp" )       ' Create Ntp object
objNtp.Activate "xyz", True                  ' Substitute xyz by your own registrationkey
                                             ' Pass True to make the activation persistent, so you need to call
                                             ' Activate only once. If you pass False, you need to call
                                             ' Activate each time the product is started

15. SnmpManager / SnmpObject Objects

15.1. Introduction

SNMP stands for Simple Network Management Protocol. Simple Network Management Protocol is a set of standards for communication with devices connected to a TCP/IP network. It is often used to communicate with hubs and switches.

Since it was developed in 1988, the Simple Network Managment Protocol has become the de facto standard for network management. Because it is a simple solution, requiring little code to implement, vendors can easily build SNMP agents to their products. SNMP is extensible, allowing vendors to easily add network management functions to their existing products. SNMP also separates the managment architecture from the architecture of the hardware devices, which broadens the base of multivendor support. Perhaps most important, unlike other so-called standards, SNMP is not a mere paper specification, but an implementation that is widely available today.

The ActiveSocket Snmp object enables you to add Snmp v1 and Snmp v2c functionality to your program.
Here is a small example (in VBScript) to show how to use the SnmpManager object:

    
Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object

objSnmpManager.Initialize                                       ' Initialize Snmp
If( objSnmpManager.LastError <> 0 ) Then
  WScript.Echo "Initialize failed, error " & objSnmpManager.LastError
  WScript.Quit
End If

objSnmpManager.ProtocolVersion = objConstants.asSNMP_VERSION_V2c ' Set SNMP protocol version before opening SNMP session
objSnmpManager.Open "192.168.1.10", "public"                    ' Open session to remote Snmp agent
If( objSnmpManager.LastError <> 0 ) Then
  WScript.Echo "Error " & objSnmpManager.LastError
Else
  objSnmpObject = objSnmpManager.Get( "system.sysName.0"  )     ' Retrieve Object Identifier value 
  If( objSnmpManager.LastError <> 0 ) Then
    WScript.Echo "Error " & objSnmpManager.LastError
  Else
    WScript.Echo "OID : "   & objSnmpObject.Value               ' Print Snmp data
    WScript.Echo "  Value:" & objSnmpObject.Value               ' Print Snmp data
    WScript.Echo "  Type:"  & objSnmpObject.Type                ' Print Snmp data
  End If
  objSnmpManager.Close()                                        ' Close session
End If

objSnmpManager.Shutdown                                         ' Uninitialize Snmp

15.2. SnmpObject object - Properties and Functions

Property Type In/Out Mand/Opt Description
OID String In/Out M SNMP Object Identifier
Type Number In/Out M SNMP data type
Value String In/Out O SNMP data value
RequestID Number Out n/a SNMP node ID
MIB properties (only set when used with the SnmpMibBrowser object):
Name String Out O SNMP object name
Path String Out O SNMP full path object name
NodeID String Out O SNMP node ID
ParentNodeID Number Out O n/a
Syntax String Out n/a SNMP OID syntax
Access Number Out n/a SNMP OID Access
Status Number Out n/a SNMP OID Status

Function Description
Clear Reset all properties

15.3. SnmpObject Object - Properties

SnmpObject.OID property

Type:

String

Description:

SNMP Object Identifier.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
...
Set objSnmpObject = objSnmpManager.Get( ".1.3.1.1.1.1" )        ' Get an SnmpObject object
WScript.Echo "OID   : " & objSnmpObject.OID                     ' Print OID
WScript.Echo "Type  : " & objSnmpObject.Type                    ' Print Type
WScript.Echo "Value : " & objSnmpObject.Value                   ' Print Value

SnmpObject.Type property

Type:

Number

Description:

SNMP data type. For an overview of all SNMP data types, check the SNMP Data Types section.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
...
Set objSnmpObject = objSnmpManager.Get( ".1.3.1.1.1.1" )        ' Get an SnmpObject object
WScript.Echo "OID   : " & objSnmpObject.OID                     ' Print OID
WScript.Echo "Type  : " & objSnmpObject.Type                    ' Print Type
WScript.Echo "Value : " & objSnmpObject.Value                   ' Print Valuef

SnmpObject.Value property

Type:

Variant

Description:

SNMP value as a string. The value type is indicated by the Type property.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
...
Set objSnmpObject = objSnmpManager.Get( ".1.3.1.1.1.1" )        ' Get an SnmpObject object
WScript.Echo "OID   : " & objSnmpObject.OID                     ' Print OID
WScript.Echo "Type  : " & objSnmpObject.Type                    ' Print Type
WScript.Echo "Value : " & objSnmpObject.Value                   ' Print Value
WScript.Echo "RequestID : " & objSnmpObject.RequestID           ' Print RequestID

SnmpObject.RequestID property

Type:

Number

Description:

This property indicates the request ID of the OID.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
...
Set objSnmpObject = objSnmpManager.Get( ".1.3.1.1.1.1" )        ' Get an SnmpObject object
WScript.Echo "OID   : " & objSnmpObject.OID                     ' Print OID
WScript.Echo "Type  : " & objSnmpObject.Type                    ' Print Type
WScript.Echo "Value : " & objSnmpObject.Value                   ' Print Value
WScript.Echo "RequestID : " & objSnmpObject.RequestID           ' Print RequestID

SnmpObject.Name property

Type:

String

Description:

'Name' is only set when the SnmpObject is returned by SnmpMibBrowser's Get or GetNext function. This property indicates the plain name of the object.

Example:

Set objSnmpMib = CreateObject( "ActiveXperts.SnmpMibBrowser" )  ' Create a new SnmpMibBrowser instance 
objSnmpMib.LoadMibFile( "c:\windows\system32\hostmib.mib" )     ' Load MIB file
Set objSnmp = objSnmpMIB.Get("iso")                             ' Get first OID
WScript.Echo "OID Name: " & objSnmp.Name                        ' Display Name

SnmpObject.Path property

Type:

String

Description:

'Path' is only set when the SnmpObject is returned by SnmpMibBrowser's Get or GetNext function. This property indicates the full-path name of the object.

Example:

Set objSnmpMib = CreateObject( "ActiveXperts.SnmpMibBrowser" )  ' Create a new SnmpMibBrowser instance 
objSnmpMib.LoadMibFile( "c:\windows\system32\hostmib.mib" )     ' Load MIB file
Set objSnmp = objSnmpMIB.Get("iso")                             ' Get first OID
WScript.Echo "OID Name: " & objSnmp.Name                        ' Display Name
WScript.Echo "OID Full-path Name: " & objSnmp.Path              ' Display Full-patt Name

SnmpObject.NodeID property

Type:

Number

Description:

'NodeID' is only set when the SnmpObject is returned by SnmpMibBrowser's Get or GetNext function.
This property indicates the node ID of the OID.

Example:

Set objSnmpMib = CreateObject( "ActiveXperts.SnmpMibBrowser" )  ' Create a new SnmpMibBrowser instance 
objSnmpMib.LoadMibFile( "c:\windows\system32\hostmib.mib" )     ' Load MIB file
Set objSnmp = objSnmpMIB.Get("iso")                             ' Get first OID
WScript.Echo "OID Name: " & objSnmp.Name                        ' Display Name
WScript.Echo "NodeID: " & objSnmp.NodeID                        ' Display NodeID

SnmpObject.ParentNodeID property

Type:

Number

Description:

'ParentNodeID' is only set when the SnmpObject is returned by SnmpMibBrowser's Get or GetNext function. This property indicates the parent node ID of the OID.

Example:

Set objSnmpMib = CreateObject( "ActiveXperts.SnmpMibBrowser" )  ' Create a new SnmpMibBrowser instance 
objSnmpMib.LoadMibFile( "c:\windows\system32\hostmib.mib" )     ' Load MIB file
Set objSnmp = objSnmpMIB.Get("iso")                             ' Get first OID
WScript.Echo "OID Name: " & objSnmp.Name                        ' Display Name
WScript.Echo "ParentNodeID: " & objSnmp.ParentNodeID            ' Display parent NodeID

SnmpObject.Syntax property

Type:

Number

Description:

'Syntax' is only set when the SnmpObject is returned by SnmpMibBrowser's Get or GetNext function. This property indicates the syntax of the object.

Example:

Set objSnmpMib = CreateObject( "ActiveXperts.SnmpMibBrowser" )  ' Create a new SnmpMibBrowser instance 
objSnmpMib.LoadMibFile( "c:\windows\system32\hostmib.mib" )     ' Load MIB file
Set objSnmp = objSnmpMIB.Get("iso")                             ' Get first OID
WScript.Echo "OID Name: " & objSnmp.Name                        ' Display Name
WScript.Echo "Syntax: " & objSnmp.Syntax                        ' Display Syntax

SnmpObject.Access property

Type:

Number

Description:

'Access' is only set when the SnmpObject is returned by SnmpMibBrowser's Get or GetNext function. Click here for a list of valid Access values

Example:

Set objSnmpManager = CreateObject ( "ActiveXperts.SnmpManager") ' Create a new SnmpManager instance
Set objConstants = CreateObject ( "ActiveXperts.ASConstants")

objSnmpManager.Server  = "ns1.interstroom.nl"                   ' Apply queries to DNS server ns1.interstroom.nl    
objSnmpManager.Lookup "activexperts.com", objConstants.asDNS_TYPE_SOA  ' Lookup SOA record for activexperts.com    
If( objSnmpManager.LastError = 0 ) Then
    WScript.Quit
End If
Set objSnmpObject = objSnmpManager.GetFirstRecord               ' Get first DNS record 
If( objSnmpManager.LastError = 0 ) Then                                
    WScript.Echo "Name: " & objSnmpObject.Name                  ' Display all SOA record fields 
    WScript.Echo "NameServer: " & objSnmpObject.NameServer
    WScript.Echo "MailBox: " & objSnmpObject.MailBox
    WScript.Echo "NameServer: " & objSnmpObject.NameServer
    WScript.Echo "SerialNumber: " & objSnmpObject.SerialNumber
    WScript.Echo "RefreshInterval: " & objSnmpObject.RefreshInterval
    WScript.Echo "RetryInterval: " & objSnmpObject.RetryInterval
    WScript.Echo "ExpirationLimit: " & objSnmpObject.ExpirationLimit
    WScript.Echo "MinimumTTL: " & objSnmpObject.MinimumTTL
End If

SnmpObject.Status property

Type:

Number

Description:

'Status' is only set when the SnmpObject is returned by SnmpMibBrowser's Get or GetNext function. Click here for a list of valid Status values

Example:

Set objSnmpMib = CreateObject( "ActiveXperts.SnmpMibBrowser" )  ' Create a new SnmpMibBrowser instance 
objSnmpMib.LoadMibFile( "c:\windows\system32\hostmib.mib" )     ' Load MIB file
Set objSnmp = objSnmpMIB.Get("iso")                             ' Get first OID
WScript.Echo "OID Name: " & objSnmp.Name                        ' Display Name
WScript.Echo "Status: " & objSnmp.Status                        ' Display Status

15.4. SnmpObject Object - Functions

SnmpObject.Clear function

Description:

Clears all properties of the object.

Parameters:

Return value:

Always 0.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
Set objSnmpObject  = CreateObject( "ActiveXperts.SnmpObject" )  ' Create a new SnmpObject instance
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
...
objSnmpObject.Clear()                                           ' Clear all properties
objSnmpObject.OID    = "1.3.1.2.3.4.5"
objSnmpObject.Type   = objConstants.asSNMP_TYPE_IPADDRESS
objSnmpObject.Value  = "10.1.1.10"
objSnmpManager.Set( objSnmpObject )                             ' SNMP Set

15.5. SnmpManager object - Properties and Functions

Property Type In/Out Mand/Opt Description
Version String Out n/a Version number of ActiveSocket
Build String Out n/a Display build information of ActiveSocket
ExpirationDate String Out n/a Expiration date of ActiveSocket
Timeout Number In/Out O Number of millseconds before an SNMP operation will time out
ProtocolVersion Number In/Out O Specifies the SNMP protocol version to use
LastError Number In/Out O Result of the last called function

Function Description
Initialize Initialize the Snmp object
Shutdown Shut down the Snmp object
Clear Reset all properties to their default values
Open Open an SNMP session to a remote host, using a specified community string
Close Close the existing SNMP session
Get Get the Snmp Data object of the specified OID (Object ID) from the (remote) SNMP agent
GetNext Retrieve the next Snmp Data object from a table or list within an SNMP agent.
Set Assign a new value to the specified OID (Object ID) on the (remote) SNMP agent
GetErrorDescription Get the description of the given error
Sleep Suspends the execution of the object for at least the specified interval
Activate Activate Software

15.6. SnmpManager Object - Properties

SnmpManager.Version property

Type:

String

Description:

Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objSnmpManager = CreateObject("ActiveXperts.SnmpManager")   ' Create a new SnmpManager instance
WScript.Echo  "Version: " & objSnmpManager.Version

SnmpManager.Build property

Type:

String

Description:

Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objSnmpManager = CreateObject("ActiveXperts.SnmpManager")   ' Create a new SnmpManager instance
WScript.Echo  "Build: " & objSnmpManager.Build

SnmpManager.ExpirationDate property

Type:

String

Description:

Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
WScript.Echo "ExpirationDate: " & objSnmpManager.ExpirationDate

SnmpManager.Port property

Type:

Number

Description:

UDP port number to identify a (remote) SNMP agent. If you don't specify the 'Port' property, port 161 (default SNMP port) is used.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
objSnmpManager.Initialize                                       ' Initialize Snmp
...
objSnmpManager.Port = 9000                                      ' Use port 9000 instead of default port 161
objSnobjSnmpManagermp.Open "192.168.1.10", "public"             ' Connect to host 192.168.1.10, community public'

SnmpManager.Timeout property

Type:

Number

Description:

Specifies the number of milliseconds before an SNMP operation times out. Default value: 5000 milliseconds.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
objSnmpManager.Initialize                                       ' Initialize Snmp
...
objSnmpManager.Timeout = 5000                                   ' Allow 5000 msecs until an SNMP operation times out
objSnmpManager.Open "192.168.1.10", "public"
...

SnmpManager.ProtocolVersion property

Type:

Number

Description:

Specifies the SNMP protocol version to use: asSNMP_VERSION_V1 or asSNMP_VERSION_V2C. The default is version asSNMP_VERSION_V2C.
Note: To set the protocol version, you must set the 'ProtocolVersion' property before calling the Open function.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
Set objConstants = CreateObject( "ActiveXperts.ASConstants" )   ' Create constants object
objSnmpManager.Initialize                                       ' Initialize Snmp
...
objSnmpManager.ProtocolVersion = objConstants.asSNMP_VERSION_V1 ' Use SNMP v1 protocol version. Set it before calling 'Open'
objSnmpManager.Open "192.168.1.10", "public"
...

SnmpManager.LastError property

Type:

Number

Description:

The result of a previous called function. Use it to check the result of your last function call. A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
objSnmpManager.Initialize                                       ' Initialize Snmp
...
objSnmpManager.Open "192.168.1.10", "public"
WScript.Echo "LastError: " & objSnmpManager.LastError
...

15.7. SnmpManager Object - Functions

SnmpManager.Initialize function

Description:

Initializes the Snmp object. Internally, the Initialize function initializes the WinSNMP libraries of the Operating System and allocates all necessary resources. You must call 'Initialize' before you can Open an SNMP session. You must call Shutdown to shut down the object (before unloading the Snmp object).

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
objSnmpManager.Initialize                                       ' Initialize Snmp
If( objSnmpManager.LastError = 0 )
  objSnmpManager.Open "192.168.1.100", "public"
  ...
  objSnmpManager.Close
  ...
  objSnmpManager.Shutdown
End If

SnmpManager.Shutdown function

Description:

Call this function to shut down the Snmp object. All resources of the object will be released.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
objSnmpManager.Initialize                                       ' Initialize Snmp
If( objSnmpManager.LastError = 0 )
  objSnmpManager.Open "192.168.1.100", "public"
  ...
  objSnmpManager.Close
  ...
  objSnmpManager.Shutdown                                       ' Uninitialize Snmp
End If

SnmpManager Clear function

Description:

Resets all properties to the initial, default values. Use this function when you are opening/closing SNMP sessions multiple times.

Parameters:

Return value:

Always 0.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
objSnmpManager.Initialize                                       ' Initialize Snmp
...
objSnmpManager.Open "192.168.1.100", "public"
If( objSnmpManager.LastError = 0 )
  ...
  objSnmpManager.Close
End If
objSnmpManager.Clear
objSnmpManager.Open "192.168.1.200", "public"
If( objSnmpManager.LastError = 0 )
  ...
  objSnmpManager.Close
End If
objSnmpManager.Shutdown                                         ' Uninitialize Snmp

SnmpManager.Open function

Description:

Opens an SNMP session to a remote host, using a specified community string.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
objSnmpManager.Initialize                                       ' Initialize Snmp
objSnmpManager.Open "192.168.1.100", "public"
If( objSnmpManager.LastError = 0 )
  WScript.Echo  "Yes, session successfully established"
  ...
  objSnmpManager.Close
End If
...

SnmpManager.Close function

Description:

Close an SNMP session that was opened by the Open function.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
objSnmpManager.Initialize                                       ' Initialize Snmp
objSnmpManager.Open "192.168.1.100", "public"
If( objSnmpManager.LastError = 0 )
  WScript.Echo  "Yes, session successfully established"
  ...
  objSnmpManager.Close
End If
...

SnmpManager.Get function

Description:

Get the value and type of the specified OID (Object ID) from the (remote) SNMP agent. You must first open a session to the remote agent using the Open function. The return value is an SnmpObject object.

Parameters:

Return value:

An SnmpObject object. If the function fails, the LastError property contains the error code.

Example:

Set objSnmpManager = CreateObject("ActiveXperts.SnmpManager")   ' Create a new SnmpManager instance
objSnmpManager.Initialize                                       ' Initialize Snmp
...
objSnmpManager.Open "192.168.1.100", "public"
If( objSnmpManager.LastError = 0 )
  Set objSnmpObject = objSnmpManager.Get( "system.sysName.0" )  ' Get SnmpObject object
  If( objSnmpManager.LastError = 0 )
    WScript.Echo "Type:  " & objSnmpObject.Type
    WScript.Echo "Value: " & objSnmpObject.Value
  End If
  Set objSnmpObject = objSnmpManager.Get(".1.3.6.1.2.1.1.5.0")  ' Get another SnmpObject object
  If( objSnmpManager.LastError = 0 )
    WScript.Echo "Type:  " & objSnmpObject.Type
    WScript.Echo "Value: " & objSnmpObject.Value
  End If
  objSnmpManager.Close
End If
...

SnmpManager.GetNext function

Description:

Retrieve the next OID from a table or list within an SNMP agent. This function should only be called after a successfull Get function call.

Parameters:

Return value:

An SnmpObject object. If the function fails, the LastError property contains the error code.

Example (SNMP walker):

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new Snmp instance
objSnmpManager.Initialize                                       ' Initialize Snmp
...
objSnmpManager.Open "192.168.1.100", "public"
If( objSnmpManager.LastError = 0 )
  Set objSnmpObject = objSnmpManager.Get( "system.sysName.0" )  ' Get SnmpObject object
  While( objSnmpManager.LastError = 0 )
    WScript.Echo "Type:  " & objSnmpObject.Type
    WScript.Echo "Value: " & objSnmpObject.Value

    Set objSnmpObject = objSnmpManager.GetNext()                ' Get next SnmpObject object
  End If
  objSnmpManager.Close
End If
...

SnmpManager.Set function

Description:

Set value and type of the SnmpObject object on the (remote) SNMP agent. You must first open a session to the remote agent using the Open function.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
Set objSnmpObject  = CreateObject( "ActiveXperts.SnmpObject" )  ' Create a new SnmpObject instance
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
objSnmpManager.Initialize                                       ' Initialize Snmp
...
objSnmpManager.Open "192.168.1.100", "public"
If( objSnmpManager.LastError = 0 )
  objSnmpObject.Clear()                                         ' Clear all properties, a good practise
  objSnmpObject.OID   = ".1.3.1.2.3.4.5.6.7.8"                  ' Specify object properties
  objSnmpObject.Type  = objConstants.asSNMP_TYPE_IPADDRESS      ' Specify object properties
  objSnmpObject.Value = "10.1.1.10"                             ' Specify object properties
  objSnmpManager.Set( objSnmpObject )                           ' Call Set
  objSnmpManager.Close
End If
...

SnmpManager.GetErrorDescription function

Description:

GetErrorDescription provides the error description of a given error code.

Parameters:

Return value:

The error description that is associated with the given error code.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create a new SnmpManager instance
objSnmpManager.Initialize                                       ' Initialize Snmp
...
objSnmpManager.Open "www.thisdoesnotexist.com", "public"
WScript.Echo "LastError: " & objSnmpManager.LastError
WScript.Echo "Error description: " & objSnmpManager.GetErrorDescription( objSnmpManager.LastError )
...

SnmpManager.Sleep function

Description:

This function can be used in your script anywhere you want; Suspends the execution of the object for at least the specified interval.

Parameters:

Return value:

Always 0.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" )  ' Create SnmpManager object
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" )  ' Create constants object
...
objSnmpManager.Sleep 500

SnmpManager.Activate function

Description:

This function activates the ActiveSocket product. A valid registration code is required.

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpManager" ) ' Create SnmpManager object
objSnmpManager.Activate "xyz", True       ' Substitute xyz by your own registrationkey
                                        ' Pass True to make the activation persistent, so you need to call
                                        ' Activate only once. If you pass False, you need to call 
                                        ' Activate each time the product is started.

16. SnmpTrapManager / SnmpTrap Objects

16.1. Introduction

An SNMP trap is simply a notification message that is transmitted by an SNMP-managed device whenever it has something of interest to report. Traps can be thought of as event messages, similar to the events in the Windows event logs. Traps, like regular SNMP variables, are defined in MIB (Management Information Base) files. They are defined as a set of SNMP variables contained in (or referenced by) an OID (Object Identifier). If you look at the system directory on any Windows machine that has SNMP installed, you will find several MIB files. (They have the extension ".mib".) If you look through them you will see the variables that are supported on that machine.
ActiveSocket has interfaces for sending and receiving SNMP traps.

The SnmpTrapManager object provides properties and functions for sending and receiving SNMP traps.

Here is a small example (in VBScript) to show how to send an SNMP trap using the SnmpTrapManager object:

    
Set objSnmpTrapManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
Set objSnmpTrap   = CreateObject( "ActiveXperts.SnmpTrap" )     ' Create a new SnmpTrap instance
Set objSnmpObject = CreateObject( "ActiveXperts.SnmpObject" )   ' Create a new SnmpObject instance
Set objConstants  = CreateObject( "ActiveXperts.ASConstants" )  ' Create a new Constants instance 
objSnmpTrapManager.Initialize                                   ' Initialize SNMP
If( objSnmpTrapManager.LastError <> 0 ) Then
  WScript.Quit
End If

' Set trap properties
objSnmpTrap.Clear()
objSnmpTrap.Host	  = "server06"
objSnmpTrap.Community = "public"

' Add a variable to the trap
objSnmpObject.Clear()                                           ' Clear trap object
objSnmpObject.OID   = ".1.3.6.1.2.1.1.5.0"                      ' Set trap properties
objSnmpObject.Type  = objConstants.asSNMP_TYPE_IPADDRESS        ' Set trap properties
objSnmpObject.Value = "10.0.0.1"                                ' Set trap properties 
objSnmpTrap.AddObject objSnmpObject                             ' Add the trap to the queue

' Add another variable to the trap
objSnmpObject.Clear()                                           ' Clear trap object
objSnmpObject.OID   = ".1.3.6.1.2.1.1.5.1"                      ' Set trap properties
objSnmpObject.Type  = objConstants.asSNMP_TYPE_OCTETSTRING      ' Set trap properties
objSnmpObject.Value = "One two three"                           ' Set trap properties 
objSnmpTrap.AddObject objSnmpObject                             ' Add the trap to the queue

objSnmpTrapManager.Send objSnmpTrap                             ' Send trap
WScript.Echo "Send, result: " & objSnmpTrapManager.LastError    ' Display the result

objSnmpTrapManager.Shutdown                                     ' Uninitialize SNMP

A small example (in VBScript) to show how to receive SNMP traps using the SnmpTrapManager object. The sample listens for incoming traps and displays the results:

    
Set objSnmpTrapManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
objSnmpTrapManager.Initialize                                   ' Initialize SNMP
If( objSnmpTrapManager.LastError <> 0 ) Then
  WScript.Quit
End If

objSnmpTrapManager.StartListening "public"                      ' Start listening now
If( objSnmpTrapManager.LastError <> 0 ) Then
   objSnmpTrapManager.Shutdown                                  ' Uninitialize SNMP
   WScript.Quit
End If

Set objSnmpTrap = objSnmpTrapManager.GetFirstTrap               ' Get trap

While( objSnmpTrapManager.LastError = 0 )
   WScript.Echo "Trap from      : " & objSnmpTrap.Host
   WScript.Echo " Community     : " & objSnmpTrap.Community

   Set objSnmpObject = objSnmpTrap.GetFirstObject      
   While( objSnmpTrap.LastError = 0 )                           ' iterate over all variables in the trap
    
     WScript.Echo "  OID : " & objSnmpObject.OID
     WScript.Echo "  Value:" & objSnmpObject.Value   
     WScript.Echo "  Type:"  & GetTypeString( objSnmpObject.Type )
  
     Set objSnmpObject = objSnmpTrap.GetNextObject
   WEnd

   Set objSnmpTrap = objSnmpTrapManager.GetNextTrap             ' Get next trap
WEnd  

objSnmpTrapManager.StopListening                                ' Stop listening for incoming traps

objSnmpTrapManager.Shutdown                                     ' Uninitialize SNMP

ActiveSocket ships with a utility to receive SNMP trap messages in the background. This program runs as a Windows service, and stored incoming traps in a database (MS Access database by default). Configration settings are stored in a plain ASCII file. For more information about this SNMP Trap Receiver Service, see Chapter 16.8: SNMP Trap Receiver Service.

16.2. SnmpTrap object - Properties and Functions

Property Type In/Out Mand/Opt Description
Host String In/Out M SNMP host
Community String In/Out M SNMP community
Port Number In/Out M SNMP port
GenericTrap Number In/Out O Generic Trap identifier
SpecificTrap Number In/Out O Specific Trap identifier (custom trap)
Enterprise String In/Out O Relative OID path
UpTime String In/Out O UpTime

Function Description
Clear Reset all properties to their default values
AddObject Add a new SNMP object to the trap
GetFirstObject Get first variable
GetNextObject Get next variable

16.3. SnmpTrap Object - Properties

SnmpTrap.Host property

Type:

String

Description:

Host or IP address. If the object is used for sending traps, the 'Host' property specifies the remote host to send the trap to. If the object is returned by the GetFirstTrap or GetNextTrap function, the 'Host' propery identifies the host where the trap was received from.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
...
objSnmpTrapManager.StartListening "public"
...
Set objSnmpTrap = objSnmpTrapManager.GetFirstTrap
While objSnmpTrapManager.LastError = 0
   WScript.Echo "Host : "    & objSnmpTrap.Host                 ' Print incoming trap properties
   WScript.Echo "  Community:"  & objSnmpTrap.Community         ' Print incoming trap properties
   WScript.Echo "  Uptime:"  & objSnmpTrap.UpTime               ' Print incoming trap properties
   WScript.Echo "  GenericTrap:"  & objSnmpTrap.GenericTrap     ' Print incoming trap properties
   WScript.Echo "  SpecificTrap:"  & objSnmpTrap.SpecificTrap   ' Print incoming trap properties
   WScript.Echo "  Enterprise:"  & objSnmpTrap.Enterprise       ' Print incoming trap properties
   WScript.Echo "  Uptime:"  & objSnmpTrap.UpTime               ' Print incoming trap properties

   Set objSnmpTrap = objSnmpTrapManager.GetNextTrap
WEnd  
...
objSnmpTrapManager.StopListening

SnmpTrap.Community property

Type:

String

Description:

Community name. If the object is used for sending traps, the 'Community' property specifies the community used for sending traps. If the object is returned by the GetFirstTrap or GetNextTrap function, the 'Community' propery identifies the community on which the trap was received from.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
...
objSnmpTrapManager.StartListening "public"
...
Set objSnmpTrap = objSnmpTrapManager.GetFirstTrap
While objSnmpTrapManager.LastError = 0
   WScript.Echo "Host : "    & objSnmpTrap.Host                 ' Print incoming trap properties
   WScript.Echo "  Community:"  & objSnmpTrap.Community         ' Print incoming trap properties
   WScript.Echo "  Uptime:"  & objSnmpTrap.UpTime               ' Print incoming trap properties
   WScript.Echo "  GenericTrap:"  & objSnmpTrap.GenericTrap     ' Print incoming trap properties
   WScript.Echo "  SpecificTrap:"  & objSnmpTrap.SpecificTrap   ' Print incoming trap properties
   WScript.Echo "  Enterprise:"  & objSnmpTrap.Enterprise       ' Print incoming trap properties
   WScript.Echo "  Uptime:"  & objSnmpTrap.UpTime               ' Print incoming trap properties

   Set objSnmpTrap = objSnmpTrapManager.GetNextTrap
WEnd  
...
objSnmpTrapManager.StopListening

SnmpTrap.Port property

Type:

Number

Description:

SNMP port. If the object is used for sending traps, the 'Port' property specifies the port used for sending traps (default: 162). If the object is returned by the GetFirstTrap or GetNextTrap function, the 'Port' propery identifies the port on which the trap was received.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
...
objSnmpTrapManager.StartListening "public"
...
Set objSnmpTrap = objSnmpTrapManager.GetFirstTrap
While objSnmpTrapManager.LastError = 0
   WScript.Echo "Host : "    & objSnmpTrap.Host                 ' Print incoming trap properties
   WScript.Echo "  Port:"  & objSnmpTrap.Port                   ' Print incoming trap properties
   WScript.Echo "  Uptime:"  & objSnmpTrap.UpTime               ' Print incoming trap properties
   WScript.Echo "  GenericTrap:"  & objSnmpTrap.GenericTrap     ' Print incoming trap properties
   WScript.Echo "  SpecificTrap:"  & objSnmpTrap.SpecificTrap   ' Print incoming trap properties
   WScript.Echo "  Enterprise:"  & objSnmpTrap.Enterprise       ' Print incoming trap properties
   WScript.Echo "  Uptime:"  & objSnmpTrap.UpTime               ' Print incoming trap properties

   Set objSnmpTrap = objSnmpTrapManager.GetNextTrap
WEnd  
...
objSnmpTrapManager.StopListening

SnmpTrap.GenericTrap property

Type:

Number

Description:

This property can only be used with SNMP v1. For a list of valid values, click here.

Example:

Set objSnmpManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
...
objTrapManager.StartListening "public"
...
Set objSnmpTrap = objTrapManager.GetFirstTrap
While objSnmpTrapManager.LastError = 0
   WScript.Echo "Host : "    & objSnmpTrap.Host                 ' Print incoming trap properties
   WScript.Echo "  Community:"  & objSnmpTrap.Community         ' Print incoming trap properties
   WScript.Echo "  Uptime:"  & objSnmpTrap.UpTime               ' Print incoming trap properties
   WScript.Echo "  GenericTrap:"  & objSnmpTrap.GenericTrap     ' Print incoming trap properties
   WScript.Echo "  SpecificTrap:"  & objSnmpTrap.SpecificTrap   ' Print incoming trap properties
   WScript.Echo "  Enterprise:"  & objSnmpTrap.Enterprise       ' Print incoming trap properties
   WScript.Echo "  Uptime:"  & objSnmpTrap.UpTime               ' Print incoming trap properties

   Set objSnmpTrap = objTrapManager.GetNextTrap
WEnd  
...
objTrapManager.StopListening

SnmpTrap.SpecificTrap property

Type:

Number

Description:

This property can only be used with SNMP v1. You can specify a custom trap type.

Example:

Set objTrapManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
...
objSnmpTrapManager.StartListening "public"
...
Set objSnmpTrap = objSnmpTrapManager.GetFirstTrap
While objSnmpTrapManager.LastError = 0
   WScript.Echo "Host : "    & objSnmpTrap.Host                 ' Print incoming trap properties
   WScript.Echo "  Community:"  & objSnmpTrap.Community         ' Print incoming trap properties
   WScript.Echo "  Uptime:"  & objSnmpTrap.UpTime               ' Print incoming trap properties
   WScript.Echo "  GenericTrap:"  & objSnmpTrap.GenericTrap     ' Print incoming trap properties
   WScript.Echo "  SpecificTrap:"  & objSnmpTrap.SpecificTrap   ' Print incoming trap properties
   WScript.Echo "  Enterprise:"  & objSnmpTrap.Enterprise       ' Print incoming trap properties
   WScript.Echo "  Uptime:"  & objSnmpTrap.UpTime               ' Print incoming trap properties

   Set objSnmpTrap = objSnmpTrapManager.GetNextTrap
WEnd  
...
objSnmpTrapManager.StopListening

SnmpTrap.Enterprise property

Type:

String

Description:

This property can only be used with SNMP v1. It indicates the relative OID.

Example:

Set objTrapManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
...
objTrapManager.StartListening "public"
...
Set objSnmpTrap = objTrapManager.GetFirstTrap
While objTrapManager.LastError = 0
   WScript.Echo "Host : "    & objSnmpTrap.Host                 ' Print incoming trap properties
   WScript.Echo "  Community:"  & objSnmpTrap.Community         ' Print incoming trap properties
   WScript.Echo "  Uptime:"  & objSnmpTrap.UpTime               ' Print incoming trap properties
   WScript.Echo "  GenericTrap:"  & objSnmpTrap.GenericTrap     ' Print incoming trap properties
   WScript.Echo "  SpecificTrap:"  & objSnmpTrap.SpecificTrap   ' Print incoming trap properties
   WScript.Echo "  Enterprise:"  & objSnmpTrap.Enterprise       ' Print incoming trap properties
   WScript.Echo "  Uptime:"  & objSnmpTrap.UpTime               ' Print incoming trap properties

   Set objSnmpTrap = objTrapManager.GetNextTrap
WEnd  
...
objTrapManager.StopListening

SnmpTrap.UpTime property

Type:

Number

Description:

Provides the amount of time that has elapsed between the last network reinitialization and generation of the trap. This property is available for both SNMP v1 and SNMP v2c.

Example:

Set objTrapManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
...
objTrapManager.StartListening "public"
...
Set objSnmpTrap = objTrapManager.GetFirstTrap
While objTrapManager.LastError = 0
   WScript.Echo "Host : "    & objSnmpTrap.Host                 ' Print incoming trap properties
   WScript.Echo "  Community:"  & objSnmpTrap.Community         ' Print incoming trap properties
   WScript.Echo "  Uptime:"  & objSnmpTrap.UpTime               ' Print incoming trap properties
   WScript.Echo "  GenericTrap:"  & objSnmpTrap.GenericTrap     ' Print incoming trap properties
   WScript.Echo "  SpecificTrap:"  & objSnmpTrap.SpecificTrap   ' Print incoming trap properties
   WScript.Echo "  Enterprise:"  & objSnmpTrap.Enterprise       ' Print incoming trap properties
   WScript.Echo "  Uptime:"  & objSnmpTrap.UpTime               ' Print incoming trap properties

   Set objSnmpTrap = objTrapManager.GetNextTrap
WEnd  
...
objTrapManager.StopListening

16.4. SnmpTrap Object - Functions

SnmpTrap.Clear function

Description:

Resets all properties to the initial, default values.

Parameters:

Return value:

Always 0.

Example:

Set objTrapManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
Set objSnmpTrap  = CreateObject( "ActiveXperts.SnmpTrap" )      ' Create a new SnmpTrap instance
...
objSnmpTrap.Clear()                                             ' Clear all properties
objSnmpTrap.Host         = ...
objSnmpTrap.Community    = ...

SnmpTrap.AddObject function

Description:

Add an SnmpObject to the trap. You can add multiple SnmpObjects to a trap.

Parameters:

Return value:

Always 0.

Example:

Set objTrapManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
Set objSnmpTrap     = CreateObject( "ActiveXperts.SnmpTrap" )   ' Create a new SnmpTrap instance
Set objSnmpObject   = CreateObject( "ActiveXperts.SnmpObject" ) ' Create a new SnmpObject instance
Set objConstants    = CreateObject( "ActiveXperts.ASConstants" )' Create a new Constants instance 
objTrapManager.Initialize     
...                                      
' Set trap properties
objSnmpTrap.Clear()
objSnmpTrap.Host	  = "server06"
objSnmpTrap.Community = "public"

' Add a variable to the trap
objSnmpObject.Clear()                                           ' Clear trap object
objSnmpObject.OID     = ".1.3.6.1.2.1.1.5.0"                    ' Set trap properties
objSnmpObject.Type    = objConstants.asSNMP_TYPE_IPADDRESS      ' Set trap properties
objSnmpObject.Value   = "10.0.0.1"                              ' Set trap properties 
objSnmpTrap.AddObject objSnmpObject                             ' Add the object to the trap

' Add another variable to the trap
objSnmpObject.Clear()                                           ' Clear trap object
objSnmpObject.OID     = ".1.3.6.1.2.1.1.5.1"                    ' Set trap properties
objSnmpObject.Type    = objConstants.asSNMP_TYPE_OCTETSTRING    ' Set trap properties
objSnmpObject.Value   = "One two three"                         ' Set trap properties 
objSnmpTrap.AddObject objSnmpObject                             ' Add the object to the trap

objTrapManager.Send objSnmpTrap                                 ' Send trap
...

SnmpTrap.GetFirstObject,
SnmpTrap.GetNextObject functions

Description:

Iterate over all SnmpTrap objects in the trap. There can be 1 or more SnmpTrap objects in one trap.

Parameters:

Return value:

A reference to an SnmpTrap object.

Example:

Set objTrapManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
objTrapManager.Initialize                                       ' Initialize SNMP
... 
objTrapManager.StartListening "public"                          ' Start listening now
...
Set objSnmpTrap = objTrapManager.GetFirstTrap                   ' Get trap
While( objTrapManager.LastError = 0 )
   WScript.Echo "Trap from      : " & objSnmpTrap.Host
   WScript.Echo "  Community   : " & objSnmpTrap.Community

   Set objSnmpObject = objSnmpTrap.GetFirstObject      
   While( objSnmpTrap.LastError = 0 )                           ' iterate over all variables in the trap
    
     WScript.Echo "OID : " & objSnmpObject.OID
     WScript.Echo "Value:" & objSnmpObject.Value   
     WScript.Echo "Type:"  & GetTypeString( objSnmpObject.Type )
  
     Set objSnmpObject = objSnmpTrap.GetNextObject
   WEnd

   Set objSnmpTrap = objTrapManager.GetNextTrap                 ' Get next trap
WEnd  

objTrapManager.StopListening                                    ' Stop listening for incoming traps
objTrapManager.Shutdown                                         ' Uninitialize SNMP

16.5. SnmpTrapManager object - Properties and Functions

Property Type In/Out Mand/Opt Description
Version String Out n/a Version number of ActiveSocket
Build String Out n/a Display build information of ActiveSocket
ExpirationDate String Out n/a Expiration date of ActiveSocket
ProtocolVersion Number In/Out O Specifies the SNMP protocol version to use
LastError Number In/Out O Result of the last called function

Function Description
Initialize Initialize the SnmpTrapManager object
Shutdown Shut down the SnmpTrapManager object
Clear Reset all properties to their default values
Send Send a trap
StartListening Start listening for incoming traps
StopListening Stop listening for incoming traps
GetFirstTrap Get first trap in the 'Inbox'
GetNextTrap Get next trap in the 'Inbox'
Sleep Suspends the execution of the object for at least the specified interval
GetErrorDescription Get the description of the given error

16.6. SnmpTrapManager Object - Properties

SnmpTrapManager.Version property

Type:

String

Description:

Version information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objTrapManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
WScript.Echo "Version: " & objTrapManager.Version

SnmpTrapManager.Build property

Type:

String

Description:

Build information of ActiveSocket. This property is read-only; you cannot assign a value to it.

Example:

Set objTrapManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
WScript.Echo "Build: " & objTrapManager.Build

SnmpTrapManager.ExpirationDate property

Type:

String

Description:

Expiration date of ActiveSocket. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.

Example:

Set objTrapManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
WScript.Echo "ExpirationDate: " & objSnmpTrapManager.ExpirationDate

SnmpTrapManager.ProtocolVersion property

Type:

Number

Description:

Specifies the SNMP protocol version to use: asSNMP_VERSION_V1 or asSNMP_VERSION_V2C. The default is version asSNMP_VERSION_V2C.
Note: To set the protocol version, you must set the 'ProtocolVersion' property before calling the Send function.

Example:

Set objTrapManager = CreateObject( "ActiveXperts.SnmpTrapManager" ) ' Create a new SnmpTrapManager instance
Set objSnmpTrap    = CreateObject( "ActiveXperts.SnmpTrap" )    ' Create a new Create a new SnmpTrap instance
Set objConstants   = CreateObject( "ActiveXperts.ASConstants" ) ' Create constants object
objTrapManager.Initialize                                       ' Initialize SNMP
...
objSnmpTrap.Host   = ...                                        ' Set trap properties
objSnmpTrap.Community = ...                                     ' Set trap properties
...
objTrapManager.ProtocolVersion = objConstants.asSNMP_VERSION_V1 ' Use SNMP v1
objTrapManager.Send objSnmpTrap                                 ' Send trap
...

SnmpTrapManager.LastError property

Type:

Number

Description:

The result of a previous called function. Use it to check the result of your last function call. A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.

Example:

Set objTrapManager = CreateObject("ActiveXperts.SnmpTrapManager")   ' Create a new SnmpTrapManager instance
objTrapManager.Initialize                                       ' Initialize SNMP
WScript.Echo "Initialize, LastError: " & objTrapManager.LastError
...
objTrapManager.Shutdown                                         ' Shutdown SNMP  
...

16.7. SnmpTrapManager Object - Functions

SnmpTrapManager.Initialize function

Description:

Initializes the SnmpTrapManager object. Internally, the Initialize function initializes the WinSNMP libraries of the Operating System and allocates all necessary resources. You must call 'Initialize' before you can Send an SNMP trap. You must call Shutdown to shut down the object (before unloading the SnmpTrapManager object).

Parameters:

Return value:

Always 0. Check LastError property to see if the function was completed successfully.

Example:

Set objTrapManager = CreateObject("ActiveXperts.SnmpTrapManager")   ' Create a new SnmpTrapManager instance
objTrapManager.Initialize                                       ' Initialize SNMP
WScript.Echo "Initialize, LastError: " & objTrapManager.LastError
...
objTrapManager.Shutdown                                         ' Shutdown SNMP

SnmpTrapManager.Shutdown function

Description:

Call this function to shut down the SnmpTrapManager object. All resources of the object will be released.

Parameters:

Return value:

Always 0. Check LastError property to see if the funct