Click here to Skip to main content
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 2-Oct-11 0:20am
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 George Jonsson 175
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 4 Oct 2011
Copyright © CodeProject, 1999-2014
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