ActiveSocket

 Product Overview

 ActiveSocket Objects:
 
 How to use

 Online Samples

 Download (.exe)

 Brochure (.pdf)

 Manual (.htm)

 Release Notes


Support

 Knowledge Base

 Forum

 Contact Support


Purchase

 Licensing

 Pricing

 Order now


Related documents

 Tutorials

 Tools


  Download ActiveSocket Network Communications Toolkit 4.1  (5094 KB - .exe file)
  Download Manual  (505 KB - .htm file)


ASP 2.x SSH Secure Shell Sample Source Code


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

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

ActiveSocket can be well integrated into ASP environments.
This document describes how ActiveSocket can be integrated into ASP projects.


Step 1: Download and install ActiveSocket

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



Step 2: Create a new Web Site

First, create a new directory on the IIS Server's file system. This directory will hold the ASP later on.

From the 'Start menu', click on 'Administrative Tools' and click on 'Internet Information Services (IIS) Manager'. Right-click on the 'Web Sites' container and choose 'New->Web Site':

    
    (Click on the picture to enlarge)

The 'Web Site Creation Wizard' is shown, guiding you thorugh the process of creating a new web site. Provide all necessary information:
  • Description - a friendly description of the new site;
  • IP / Port / Host Header - choose your preferred way to distinguish between other web sites on the server;
  • Path - select the directory that will store the ASP file(s);
  • Web Site Access Permissions - in the Web Site Access Permissions dialog, enable 'Read' and 'Run scripts (such as ASP)';
You're now able to write an ASP script to use IP protocols with ActiveSocket.



Step 3: Create the ActiveSocket object in ASP

Create a new ASP script called DEFAULT.ASP in the directory that was created in Step2, using your favorite editor. On top of the ASP code, insert the following lines to declare and create the ActiveSocket object:
   <object runat=server progid="ActiveXperts.Ssh" id=objSsh></object>





Step 4: Test a small piece of ASP

Now, test if your new web site is working well with ActiveSocket using your browser. If you are using Microsoft Internet Explorer, it is recommended to disable friendly error message because this default setting doesn't show any ASP error message, making it hard to debug if there are any problems:
  • Choose' Internet Options' from the 'Tools' menu;
  • Select the 'Advanced' tab;
  • In the 'Browsing' folder, de-select the 'Show friendly HTTP error messages' option;
  • Click 'OK' to close the dialog.
Now, use the following piece of code in your DEFAULT.ASP page:
   
<object runat=server progid="ActiveXperts.Tcp" id=objSocket> </object>

<%
  Function WaitForData( o )
    nRetr = 0
    Do While nRetr < 5 and o.HasData () = 0
        o.Sleep 2000
        nRetr = nRetr + 1
    Loop
  End Function
%>

<%
If Request( "BUTTON_LIST" ) <> "" Then
  
  objSocket.Protocol = objSocket.asPROTOCOL_TELNET
  objSocket.Connect Request( "STR_MAILSERVER" ), 110
  Response.Write "Connect, result: " & objSocket.LastError & _
                 " (" & objSocket.GetErrorDescription( objSocket.LastError ) &  ") <br>"

  If objSocket.LastError = 0 Then

    ' YES, we established a connection

    WaitForData( objSocket )
    str = objSocket.ReceiveString
    Response.Write "ReceiveString: " & str & "<br>"

    objSocket.Sleep 1000
    str = "user " & Request( "STR_USERNAME" )
    objSocket.SendString str, True
    Response.Write "Send: " & str & " , result = " & objSocket.LastError & "<br>"

    WaitForData( objSocket )
    str = objSocket.ReceiveString
    Response.Write "ReceiveString: " & str & "<br>"

    If Left( str, 3 ) = "+OK" Then
      objSocket.Sleep 1000
      str = "pass " & Request( "STR_PASSWORD" )
      objSocket.SendString str, True
      Response.Write "Send: " & str & " , result = " & objSocket.LastError & "<br>"

      WaitForData( objSocket )
      str = objSocket.ReceiveString
      Response.Write "ReceiveString: " & str & "<br>"

      If Left( str, 3 ) = "+OK" Then
        objSocket.Sleep 1000
        str = "List"
        objSocket.SendString str, True
        Response.Write "Send: " & str & " , result = " & objSocket.LastError & "<br>"

        WaitForData( objSocket )

        str = objSocket.ReceiveString
        Response.Write "ReceiveString: " & str & "<br>"
      End If
    End If

    ' And finally, disconnect
    objSocket.Disconnect
  End If

  Response.Write "Ready.<br>"

Else
%>

  <html>
  <body>

  <hr>
  <h1>ActiveSocket <% = objSocket.Version %> demo.</h1>
  Expiration date: <% = objSocket.ExpirationDate %><br>
  <hr>
  <br>
  <form action="default.asp" method=post>
    <table>
    <td width="20"></td><td>Mailserver:</td><td><input size=40 type=text name="STR_MAILSERVER" value="pop3.mailserver.dom"></td><tr>
    <td></td><td>Username:</td><td><input size=40 type=text name="STR_USERNAME" value="myaccountname"></td><tr>
    <td></td><td>Password:</td><td><input size=40 type=password name="STR_PASSWORD" value=""></td><tr>
    <td></td><td><input type=Submit name="BUTTON_LIST" value="List"></td><td>Wait for a couple of seconds for the result.</td><tr>
    </table>
  </form>

  </body>
  </html>

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





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

Copyright ©1999-2007 ActiveXperts Software. All rights reserved.