Click here to Skip to main content
13,050,896 members (59,387 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi friends,

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

TcpClient tcpclient = new TcpClient();
                tcpclient.Connect("", 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);

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,,,
Posted 1-Oct-11 0:58am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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
carlos pin 1-Oct-11 7:25am
I read your answer, and I think your response is not appropriate to my problem, i haven't told about http protocol, my protocole is the same of telnet protocol, because I have to connect to my router and send the username and password (login), and after I can send commands to my router...this is what i want,,,how can i do it?because always i'm coonecting to my router he ask me about the username and password,,,
Espen Harlinn 1-Oct-11 7:43am
You didn't specify the the http protocol, but you told us that you where able to connect to the router using your browser - that's just another way to tell us that the router supports the http protocol. I've included a link to a nice telnet library in an update to my answer :)
SAKryukov 1-Oct-11 11:17am
Good point, my 5.
Espen Harlinn 1-Oct-11 11:52am
Thank you, Sergey!
Kim Togo 1-Oct-11 13:11pm
My 5 for at good answer that will help OP to solve the problem :-)
Espen Harlinn 1-Oct-11 13:14pm
Thank you, Kim!
carlos pin 1-Oct-11 14:39pm
I think my question is clear,,,
I am Italian and I do not speak English very well, and I'm sad not to find a solution for my problem (é_è), thank you friends
Bala Selvanayagam 2-Oct-11 6:14am
not sure this can help you
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

carlos pin 1-Oct-11 14:40pm
what can help me this link? maybe explain the TcpClient?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 2 Oct 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100