如何在Tcpclient中使用NegotiateStream? [英] How to use NegotiateStream with Tcpclient ?

查看:137
本文介绍了如何在Tcpclient中使用NegotiateStream?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,

我正在尝试登录(验证)我的路由器192.168.1.1和端口23,也分别登录了username ="admin"和password ="admin",并且使用的代码是:

Hi friends,

I''m trying to login (Authenticate) to my router 192.168.1.1 and port 23, the username="admin" and password="admin" also, and the code used is :

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
            {
                
            }



1-我的路由器连接到23端口,
2-我可以很好地用浏览器登录路由器,

请帮助我在Asycrous方法中将NegotiateStream与Tcpclient一起使用,"



1-My router is lestening to 23 port,
2-I can login to my router with browser very well,

please help me to use NegotiateStream with Tcpclient in Asycrous methode,,,

推荐答案

您昨天发布了一个类似的问题: ^ ]

1-我的路由器正驶向23端口,
2-我可以用浏览器很好地登录我的路由器

似乎表明路由器具有内置的Web服务器-这很常见.

因此,您需要使用 http协议 [快速工具:简约的Telnet库 [ ^ ]

最好的问候
Espen Harlinn
You posted a simialr question yesterday:How to login automatically to my router ?[^]

1-My router is lestening to 23 port,
2-I can login to my router with browser very well

Seems to indicate that the router has a built-in web server - and that''s common.

So you need to "talk" to it using the http protocol[^] - it will reply with HTML, that you need to parse.

E.F. Nijboer answer yesterday about using the HttpWebResponse class will solve your problem, but you probably need to read up on the topic - and that a lot of information.

[Update]
Telnet is another common protocol that can be used with many routers - here is a nice little implementation of a telnet client in c#:Quick tool : A minimalistic Telnet library[^]

Best regards
Espen Harlinn


检查此链接是否有帮助

http://msdn.microsoft.com/en-us/library/ms145193.aspx [ ^ ]
Check this Link if it helps out

http://msdn.microsoft.com/en-us/library/ms145193.aspx[^]


看这里:

http://www.leastprivilege.com/NegotiateStreamSample.aspx [ http://www.winsocketdotnetworkprogramming.com/managediostreamreaderwriter2j.html [
Look here :

http://www.leastprivilege.com/NegotiateStreamSample.aspx[^]

http://www.winsocketdotnetworkprogramming.com/managediostreamreaderwriter2j.html[^]

Good like carlos


这篇关于如何在Tcpclient中使用NegotiateStream?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆