can anybody help me transcribe this into vb.net

public string WriteNReadBuffer(byte [] TelnetNegotiation, NetworkStream stream)
    {
            stream.Write(TelnetNegotiation, 0, TelnetNegotiation.Length);
            Byte[] data = new Byte[256];
            Int32 bytes = stream.Read(data, 0, data.Length);
            string returnval;
            returnval = BitConverter.ToString(data, 0, bytes) + "\r\n";
            //textBox2.AppendText(BitConverter.ToString(data, 0, bytes) + "\r\n");
            return returnval;
    }
        public void Wait4Prompt(string PromptSearch, NetworkStream stream)
        {
            Byte[] data6 = new Byte[256];
            Int32 bytes6 = stream.Read(data6, 0, data6.Length);
            string bufferstring = (BitConverter.ToString(data6, 0, bytes6) + "\r\n");

            //Wait for particular prompt - Look for hex value for login: or password:
            while ((bufferstring.Contains(PromptSearch) != true))
            {
                Byte[] data7 = new Byte[256];
                Int32 bytes7 = stream.Read(data7, 0, data7.Length);
                bufferstring = (BitConverter.ToString(data7, 0, bytes7) + "\r\n");
            }
        }


        private void button3_Click(object sender, EventArgs e)
        {
            string server = "10.x.x.x";
            Int32 port = 23;
            TcpClient client = new TcpClient(server, port);
            NetworkStream stream = client.GetStream();

//          WONT terminal type, window size, x display location, new environment option, environment option
            textBox2.AppendText(WriteNReadBuffer(new byte[] { 255, 252, 24, 255, 252, 31, 255, 252, 35, 255, 252, 39, 255, 252, 36 }, stream));

//          DO echo, suppress go ahead
            textBox2.AppendText(WriteNReadBuffer(new byte[] { 255, 253, 01, 255, 253, 03 }, stream));

            //Wait for login prompt - Look for hex value for login:
            Wait4Prompt("6C-6F-67-69-6E-3A-20\r\n",stream);

//          Send user1
            textBox2.AppendText(WriteNReadBuffer(new byte[] { 117, 115, 101, 114, 49, 13, 10 }, stream));

            //Wait for password prompt - Look for hex value for password:
            Wait4Prompt("50-61-73-73-77-6F-72-64-3A-20", stream);                    
//          Send pass1
            textBox2.AppendText(WriteNReadBuffer(new byte[] { 112, 97, 115, 115, 49, 13, 10 }, stream));
//          Send pass1
            textBox2.AppendText(WriteNReadBuffer(new byte[] { 112, 97, 115, 115, 49, 13, 10 }, stream));

//         Wait for last login message - Look for hex value for last login:
            Wait4Prompt("4C-61-73-74-20-6C-6F-67-69-6E-3A-20", stream);
//          Send ./sync
            textBox2.AppendText(WriteNReadBuffer(new byte[] { 46, 47, 115, 121, 110, 99, 13, 10 }, stream));
            
            stream.Close();
            client.Close(); 


        }

Hi! Nice to hear that you got answer to your problem. Could you please mark the thread as solved. Thank you!

This article has been dead for over six months. Start a new discussion instead.