如何通过套接字传递用户和Pwrd(Tcpclient)? [英] how to pass User and Pwrd with Sockets (Tcpclient)?

查看:87
本文介绍了如何通过套接字传递用户和Pwrd(Tcpclient)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要登录到我的服务器,并完成了建立连接的工作.但是如何传递用户名和密码?

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

推荐答案

您可以使用特殊的服务器命令,例如在IMAP和POP服务器中使用
我们使用 userID userid pass 密码
用于登录我们的邮箱.
在服务器中定义一些命令,并使用参数从客户端发送这些命令.
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.


这篇关于如何通过套接字传递用户和Pwrd(Tcpclient)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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