返回首页

嗨,

我需要登录到我的服务器上,并尽可能建立连接了。但我怎么通过用户名和密码?

TcpClient tcpclient = new TcpClient();

            try

            {

                tcpclient.Connect("192.168.1.1", 23);

                NetworkStream ns = tcpclient.GetStream();

 

 

                byte[] inStream = new byte[10025];

                ns.Read(inStream, 0, (int)tcpclient.ReceiveBufferSize);

                string returndata = System.Text.Encoding.ASCII.GetString(inStream);

                Console.WriteLine("Data from Server : " + returndata);

                //string password = "admin";

                

 

                

                byte[] msg = Encoding.ASCII.GetBytes("admin");

                ns.Write(msg, 0, msg.Length);

                ns.Flush();

 

                

            }

            catch

            {

                

            }

我需要你的帮助,谢谢啦 卡洛斯针

回答