Click here to Skip to main content
15,885,956 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi guys,

I need to login to my server, and got as far as creating the connection. But how do I pass a username and password?

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


I need your helps,,,Thank You Friends
Posted
Comments
Bala Selvanayagam 2-Oct-11 6:13am    
try...

http://www.codeproject.com/KB/IP/MinimalisticTelnet.aspx
carlos pin 2-Oct-11 8:07am    
Thank you Bala Selvanayagam for your help, and this is exactelly what i want +

1 solution

You can use special server commands, for example in IMAP and POP servers
we use userID userid and pass password
for logging in our mailboxes.
define some commands in your server and send those commands from client side with parameters.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900