Python SimpleXMLRPCServer中客户端的IP地址? [英] IP address of client in Python SimpleXMLRPCServer?
本文介绍了Python SimpleXMLRPCServer中客户端的IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 SimpleXMLRPCServer 服务器(Python).
I have a SimpleXMLRPCServer server (Python).
如何在请求处理程序中获取客户端的IP地址?
How can I get the IP address of the client in the request handler?
此信息出现在日志中.但是,我不确定如何从请求处理程序中访问此信息.
This information appears in the log. However, I am not sure how to access this information from within the request handler.
推荐答案
如Michael所述,您可以从请求处理程序中获取client_address
.例如,您可以覆盖从BaseRequestHandler
间接继承的__init__
函数.
As Michael noted, you can get client_address
from within the request handler. For instance, you can override the __init__
function which is inherited indirectly from BaseRequestHandler
.
class RequestHandler(SimpleXMLRPCRequestHandler):
def __init__(self, request, client_address, server):
print client_address # do what you need to do with client_address here
SimpleXMLRPCRequestHandler.__init__(self, request, client_address, server)
这篇关于Python SimpleXMLRPCServer中客户端的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文