Skip to content

SSH.TCPTunnel

Andrew Lambert edited this page Nov 11, 2020 · 25 revisions

SSH.TCPTunnel

Class Declaration

 Protected Class TCPTunnel
 Inherits SSH.Channel

Remarks

This class represents a TCP/IP tunnel between your app and a third party using the SSH server as an intermediary. Traffic between your app and the SSH server is protected by SSH's encryption, however traffic between the SSH server and the third party is not.

To initiate an outbound connection from your app call the Connect() method. To listen for inbound connections from a third-party refer to the TCPListener class.

Example

This example forwards an HTTP request through the SSH server to www.example.com:80.

  Dim session As SSH.Session = SSH.Connect("ssh.example.com", 22, "username", "password")
  Dim tunnel As New SSH.TCPTunnel(Session)
  tunnel.RemoteAddress = "www.example.com"
  tunnel.RemotePort = 80
  If Not tunnel.Connect() Then MsgBox("Unable to open tunnel.")

  ' write to the tunnel
  tunnel.Write( _
     "GET / HTTP/1.0" + EndOfLine.Windows + _
     "Host: www.example.com" + EndOfLine.Windows + _
     "Connection: close" + EndOfLine.Windows + EndOfLine.Windows)
  
  ' read from the tunnel
  Dim output As String
  Do Until tunnel.EOF
    If tunnel.PollReadable() Then
      output = output + tunnel.Read(tunnel.BytesReadable)
    End If
  Loop

Event definitions

Methods

Properties

See also

Clone this wiki locally