+ Post New Thread
Results 1 to 5 of 5
Coding Thread, vb.net telnet commands in Coding and Web Development; our new projector has a web interface as well as telnet (for some reason) I'm not sure if the web ...
  1. #1

    Join Date
    May 2010
    Posts
    990
    Thank Post
    98
    Thanked 74 Times in 60 Posts
    Rep Power
    45

    vb.net telnet commands

    our new projector has a web interface as well as telnet (for some reason) I'm not sure if the web interface has an API

    Anyway thought it would be nice of me, instead of using a remote - to develop a small application thatll turn the projector on and off.

    I've wrote the program but it doesnt seem to work as intended (probably to do with my lack of coding fu) doesn't help the fact i've no idea what the program is doing when its running (would be handy to see a telnet window as its doing its stuff)

    here's the code im trying to use well the sub that i pass a value to anyway

    Code:
        Public Sub projectorcontrol(ByVal onoroff)
    
            Dim client As Net.Sockets.TcpClient
            Dim sr As IO.StreamReader
            Dim sw As IO.StreamWriter
            Dim ns As Net.Sockets.NetworkStream
            Dim response As String
    
            'connecting to a server
            client = New Net.Sockets.TcpClient
            Try
                client.Connect(projectorip, 10000) ' 10000 is the port number
            Catch e As Exception
                MessageBox.Show("Failed to connect: " & e.ToString, "Error")
                Return
            End Try
    
            ns = client.GetStream
            sr = New IO.StreamReader(ns, System.Text.Encoding.ASCII, True) ' this sends our commands to the server
            sw = New IO.StreamWriter(ns)  ' and this will read server's response
    
            sw.WriteLine("****" & ControlChars.CrLf) ' send pin number
    
            sw.Flush()
    
            sw.WriteLine(onoroff & ControlChars.CrLf) ' on or off is c00 on, c02 off
    
            response = sr.ReadLine()
    
        End Sub
    The form is just two huge buttons saying ON OFF respectively

  2. #2

    Join Date
    Jan 2009
    Location
    Burton On Trent
    Posts
    126
    Thank Post
    22
    Thanked 28 Times in 20 Posts
    Rep Power
    16
    I seem to remember that the telnet protocol isn't as straight forward as just sending data over tcp.
    You need to 1st send some configuration data (something about if you are accepting echo, and go ahead signals)
    You have to send a 2 byte commands (255 <command>) the 255 states that the next byte is an instruction and not a character.

    It's been a long time since I programmed a telnet client, but there should be plenty of info out on the googlesphere if you search telnet protocol.

    Hope this points you in the right direction.
    Pete.

  3. #3

    Join Date
    May 2010
    Posts
    990
    Thank Post
    98
    Thanked 74 Times in 60 Posts
    Rep Power
    45
    Thanks pete,

    Been pretty much on hold as it's hard to test (i'm building then running to the hall to test, fails then repeat!) , some kind of output window would be beneficial then I can see if it's sending the right information.
    Not a critical piece of code just one to help out

    mark

  4. #4

    Join Date
    Jan 2006
    Location
    Surburbia
    Posts
    2,178
    Thank Post
    74
    Thanked 307 Times in 243 Posts
    Rep Power
    115
    Don't know if this Telnet class is any good (a glance suggests it will do), but I would find a free dotNet telnet class.


    Failing that, I happily did cert authenticated SSH sessions to modify large amounts of config on some network gadgets a few years ago by simply calling the puTTY command line util from my dotNet code (puTTY does telnet too).

  5. Thanks to PiqueABoo from:

    caffrey (25th October 2011)

  6. #5

    Join Date
    May 2010
    Posts
    990
    Thank Post
    98
    Thanked 74 Times in 60 Posts
    Rep Power
    45
    cheers, i'll look into that too

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 1
    Last Post: 25th May 2011, 01:14 PM
  2. VB.net get free space
    By Quackers in forum Coding
    Replies: 2
    Last Post: 16th July 2008, 01:56 PM
  3. Replies: 8
    Last Post: 3rd June 2008, 10:23 AM
  4. VB.Net running on your network?
    By Andi in forum Windows
    Replies: 9
    Last Post: 7th November 2007, 08:40 AM
  5. VB.Net Help
    By mloveless in forum Coding
    Replies: 2
    Last Post: 29th June 2007, 04:24 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •