简体   繁体   English

如何在python中使用SocketServer获取客户端的Name属性?

[英]How can I get a client's Name attribute with SocketServer in python?

I'm using a class RequestHandler(SocketServer.BaseRequestHandler) to handle incoming connections to a server. 我正在使用类RequestHandler(SocketServer.BaseRequestHandler)处理与服务器的传入连接。

I am trying to get the name of the client which is stored as an attribute that sends data to this server, but right now I can only get it by asking for self.client_address which returns a tuple like Name of client that sent request: ('127.0.0.1', 57547) . 我正在尝试获取存储为将数据发送到该服务器的属性的客户端名称,但是现在我只能通过请求self.client_address来获取它,该参数返回一个元组,例如Name of client that sent request: ('127.0.0.1', 57547)

Is there a way to ask for an attribute of the object that initiated the connection? 有没有办法询问发起连接的对象的属性?

No . 不行 You would have to send that name over the communication channel. 您必须通过通信渠道发送该名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Python的socketserver.TCPServer强制进行相互身份验证? - How can I enforce mutual authentication using Python's socketserver.TCPServer? 使用 python socketserver 如何将变量传递给处理程序类的构造函数 - With python socketserver how can I pass a variable to the constructor of the handler class 我可以将Python SocketServer类用于此实现吗? - Can I use the Python SocketServer class for this implementation? 如何在Python中禁用socketserver的输出? - How can you disable the output of socketserver in Python? Python 的 Socketserver 到 Telnet 错误 - Python's Socketserver to Telnet errors 如何在Python的SocketServer中允许或拒绝远程连接? - How to allow or deny remote connections in Python's SocketServer? 如何从 python 中 twitter 中的用户数据字典中获取/访问“名称”属性? - How can I get/access the 'name' attribute from the user data dictionary in twitter in python? 在Python中使用描述符协议时如何获取属性名称? - How can I get the attribute name when working with descriptor protocol in Python? 如何使用Python的ElementTree转义属性名称中的冒号? - How do I escape colons in an attribute name with Python's ElementTree? 如何获取一个Python SocketServer,直到字符串被NUL终止 - How to get a python SocketServer to received until string is terminated with NUL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM