VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Telnet sample; this sample show how to establish a telnet session to a remote Telnet server using V

by Anonymous (267 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sun 4th May 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Telnet sample; this sample show how to establish a telnet session to a remote Telnet server using VBScript. Can be used on Windows

Rate Telnet sample; this sample show how to establish a telnet session to a remote Telnet server using V



' Download it from http://www.vahland.com/pub/asocket.dll
' and register it on your machine.
' Read http://www.vahland.com/pub/asocket.htm for more info

' Constants: Connection states
Const asCONN_DISCONNECTED=1
Const asCONN_LISTENING=2
Const asCONN_CONNECTED=3

' Constants: Some Error codes
Const asERR_SUCCESS=0
Const asERR_INVALIDPARAMETER=1
Const asERR_CREATETHREADFAILED=2
Const asERR_EVALUATIONEXPIRED=3
Const asERR_INVALIDLICENSE=4

' Constants: Protocols
Const asPROTOCOL_RAW=1
Const asPROTOCOL_TELNET=2

' Create a socket instance
WScript.Echo "Be sure to have the FREEWARE ASocket.dll registered on your system"
WScript.Echo "Check out the code header about how to obtain the component."
Set asObj = CreateObject("ActivXperts.Socket")
asObj.Protocol = asPROTOCOL_TELNET

' Write some information to console
WScript.Echo "ActivSocket " & asObj.Version & " demo."

' Make a connection to port 1500 on remote server
asObj.Connect "www.activxperts.com", 80
Wscript.Echo "Connect to www.activxperts.com:80, result: " & asObj.LastError
If asObj.LastError = 11001 Then
WScript.Echo "Error 11001: Specify a valid hostname-parameter in the Connect-method."
End If

If asObj.LastError = asERR_SUCCESS And asObj.ConnectionState = asCONN_CONNECTED Then

    ' YES, connection established.
    WScript.Echo "Connection established" & vbCrLf

    strReceived = ""
    nCounter = nCounter + 1

    asObj.Sleep 1000

    asObj.SendString "GET /activsocket/demopage/ HTTP/1.1", True
    asObj.SendString "Host: www.activxperts.com" & vbCrlf, True

    asObj.Sleep 1000

    If asObj.HasData Then
        strReceived = asObj.ReceiveString
  WScript.Echo "RECV: " & strReceived
    End If
      
    asObj.Sleep 1000

' And finally, disconnect
    asObj.Disconnect
End If


Download this snippet    Add to My Saved Code

Telnet sample; this sample show how to establish a telnet session to a remote Telnet server using V Comments

No comments have been posted about Telnet sample; this sample show how to establish a telnet session to a remote Telnet server using V. Why not be the first to post a comment about Telnet sample; this sample show how to establish a telnet session to a remote Telnet server using V.

Post your comment

Subject:
Message:
0/1000 characters