Click here to Skip to main content
11,706,007 members (58,665 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0 C#3.0 C# C#4.0
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 1-Oct-11 23:20pm
Comments
Bala Selvanayagam at 2-Oct-11 6:13am
   
try...

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

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 208
1 Sergey Alexandrovich Kryukov 142
2 Inimicos 60
3 ppolymorphe 57
4 ProgramFOX 50
0 OriginalGriff 9,037
1 Sergey Alexandrovich Kryukov 8,417
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,626


Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 4 Oct 2011
Copyright © CodeProject, 1999-2015
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