[英]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.