[英]User Authentication in indy tcp server
i am trying to write a telnet type program to read data from indy tcpserver 我正在尝试编写telnet类型的程序以从indy tcpserver读取数据
I want the user to first authenticate .. which is easy .. but the problem is where do I keep this authentication result so when the client executes another command, my tcpserver would know that this is an authenticated user and return data accordingly. 我希望用户首先进行身份验证..这很容易..但是问题是我应将此身份验证结果保存在何处,因此当客户端执行另一命令时,我的tcpserver会知道这是已身份验证的用户,并相应地返回数据。
I hope I was specific.. and sorry for my English i'm from Venezuela. 我希望我很具体..对不起我的英语我来自委内瑞拉。
TIdPeerThread
in Indy 9, and TIdContext
in Indy 10, both have a Data
property that you can store whatever you want in it. TIdPeerThread
在印第安纳波利斯9和TIdContext
在印第安纳波利斯10中,有一个Data
,你可以存储任何你想让它财产。
A better option is to derive a new class from TIdPeerThread
/ TIdServerContext
instead, add your custom fields/properties to that class as needed, and then assign that class to the server's ThreadClass
/ ContextClass
property. 更好的选择是从
TIdPeerThread
/ TIdServerContext
派生一个新类,然后根据需要将自定义字段/属性添加到该类,然后将该类分配给服务器的ThreadClass
/ ContextClass
属性。 Each command handler can then type-cast the provided APeerThread
/ AContext
object to your class type to access your custom data. 然后,每个命令处理程序都可以将提供的
APeerThread
/ AContext
对象类型转换为您的类类型,以访问您的自定义数据。
You should look at the source code for Indy's own components that support user authentication, such as TIdPOP3Server
and TIdSMTPServer
, to see how they persist authentication data between commands. 您应该查看Indy自己的支持用户身份验证的组件的源代码,例如
TIdPOP3Server
和TIdSMTPServer
,以查看它们如何在命令之间保留身份验证数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.