当前位置: 首页>>代码示例>>Python>>正文


Python SocketServer.ThreadingTCPServer方法代码示例

本文整理汇总了Python中SocketServer.ThreadingTCPServer方法的典型用法代码示例。如果您正苦于以下问题:Python SocketServer.ThreadingTCPServer方法的具体用法?Python SocketServer.ThreadingTCPServer怎么用?Python SocketServer.ThreadingTCPServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SocketServer的用法示例。


在下文中一共展示了SocketServer.ThreadingTCPServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import ThreadingTCPServer [as 别名]
def __init__(self, addr = ('localhost', 8000),
        RequestHandler = SOAPRequestHandler, log = 0, encoding = 'UTF-8',
        config = Config, namespace = None, ssl_context = None):

        # Test the encoding, raising an exception if it's not known
        if encoding != None:
            ''.encode(encoding)

        if ssl_context != None and not config.SSLserver:
            raise AttributeError, \
                "SSL server not supported by this Python installation"

        self.namespace          = namespace
        self.objmap             = {}
        self.funcmap            = {}
        self.ssl_context        = ssl_context
        self.encoding           = encoding
        self.config             = config
        self.log                = log

        self.allow_reuse_address= 1

        SocketServer.ThreadingTCPServer.__init__(self, addr, RequestHandler)

# only define class if Unix domain sockets are available 
开发者ID:donSchoe,项目名称:p2pool-n,代码行数:27,代码来源:Server.py

示例2: run

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import ThreadingTCPServer [as 别名]
def run(self, ip='0.0.0.0', port=3240):
        #SocketServer.TCPServer.allow_reuse_address = True
        self.server = SocketServer.ThreadingTCPServer((ip, port), USBIPConnection)
        self.server.usbcontainer = self
        self.server.serve_forever() 
开发者ID:Frazew,项目名称:PythonUSBIP,代码行数:7,代码来源:USBIP.py

示例3: __init__

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import ThreadingTCPServer [as 别名]
def __init__(self):
        super(server, self).__init__()
        self.srv = SocketServer.ThreadingTCPServer((CTCore.HOST, CTCore.PORT), TCPHandler) 
开发者ID:omriher,项目名称:CapTipper,代码行数:5,代码来源:CTServer.py

示例4: __init__

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import ThreadingTCPServer [as 别名]
def __init__(self, remote_server, ssh_transport, *args, **kwargs):
		self.remote_server = remote_server
		self.ssh_transport = ssh_transport
		socketserver.ThreadingTCPServer.__init__(self, *args, **kwargs) 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:6,代码来源:ssh_forward.py

示例5: test_ThreadingTCPServer

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import ThreadingTCPServer [as 别名]
def test_ThreadingTCPServer(self):
        self.run_server(SocketServer.ThreadingTCPServer,
                        SocketServer.StreamRequestHandler,
                        self.stream_examine) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_socketserver.py

示例6: handle_error

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import ThreadingTCPServer [as 别名]
def handle_error(self, *args):
        """make ThreadingTCPServer happy"""
        etype, value = sys.exc_info()[:2]
        if isinstance(value, NetWorkIOError) and 'bad write retry' in value.args[1]:
            etype = value = None
        else:
            del etype, value
            SocketServer.ThreadingTCPServer.handle_error(self, *args) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:10,代码来源:web_control.py

示例7: main

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import ThreadingTCPServer [as 别名]
def main():
    import argparse
    global trace_file, TARGET_HOST, TARGET_PORT

    HOST, PORT = "localhost", 8090

    parser = argparse.ArgumentParser()
    parser.add_argument('-t', '--trace_file', type=argparse.FileType('w'))
    parser.add_argument('-b', '--bind', default=HOST)
    parser.add_argument('-p', '--port', type=int, default=PORT)
    parser.add_argument('-n', '--negotiate', help='Negotiate with the given server name')
    parser.add_argument('TARGET_HOST')
    parser.add_argument('TARGET_PORT', type=int)

    args = parser.parse_args()

    TARGET_HOST = args.TARGET_HOST
    TARGET_PORT = args.TARGET_PORT

    trace_file = args.trace_file

    register_types()

    NETTCPProxy.negotiate = bool(args.negotiate)
    NETTCPProxy.server_name = args.negotiate

    if GSSAPIStream is None and NETTCPProxy.negotiate:
        log.error("GSSAPI not available, negotiation not possible. Try python2 with gssapi")
        sys.exit(1)

    server = SocketServer.ThreadingTCPServer((args.bind, args.port), NETTCPProxy)

    server.serve_forever() 
开发者ID:ernw,项目名称:net.tcp-proxy,代码行数:35,代码来源:proxy.py

示例8: start_server

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import ThreadingTCPServer [as 别名]
def start_server(debugflag=False):
	try:
		server = socketserver.ThreadingTCPServer(("", 50000), ServerSocket)
		server.conn = debugflag
		print "[DAEMON] Hellman Server Started"
		server.serve_forever()
	except:
		pass 
开发者ID:RussianOtter,项目名称:networking,代码行数:10,代码来源:DH.py

示例9: __init__

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import ThreadingTCPServer [as 别名]
def __init__(self, host='localhost',
                 port=None,
                 handler=LogRecordStreamHandler):
        if port is None:
            port = logging.handlers.DEFAULT_TCP_LOGGING_PORT
        SocketServer.ThreadingTCPServer.__init__(self, (host, port), handler) 
开发者ID:automl,项目名称:HPOlib,代码行数:8,代码来源:LoggingWebMonitor.py

示例10: __init__

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import ThreadingTCPServer [as 别名]
def __init__(self, port=8000):
        self._server_address = ("127.0.0.1", port)
        self._handler = SimpleHTTPRequestHandlerHere
        self.httpd = ThreadingTCPServer(
            self._server_address, self._handler, bind_and_activate=False
        ) 
开发者ID:XLSForm,项目名称:pyxform,代码行数:8,代码来源:server.py

示例11: __init__

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import ThreadingTCPServer [as 别名]
def __init__(self, *args, **kwargs):
        self.cfg = Config()
        self.analysistasks = {}
        self.analysishandlers = {}

        ip = self.cfg.resultserver.ip
        self.port = int(self.cfg.resultserver.port)
        while True:
            try:
                server_addr = ip, self.port
                SocketServer.ThreadingTCPServer.__init__(self,
                                                         server_addr,
                                                         ResultHandler,
                                                         *args,
                                                         **kwargs)
            except Exception as e:
                # In Linux /usr/include/asm-generic/errno-base.h.
                # EADDRINUSE  98 (Address already in use)
                # In Mac OS X or FreeBSD:
                # EADDRINUSE 48 (Address already in use)
                if e.errno == 98 or e.errno == 48:
                    log.warning("Cannot bind ResultServer on port {0}, "
                                "trying another port.".format(self.port))
                    self.port += 1
                else:
                    raise CuckooCriticalError("Unable to bind ResultServer on "
                                              "{0}:{1}: {2}".format(
                                                  ip, self.port, str(e)))
            else:
                log.debug("ResultServer running on {0}:{1}.".format(ip, self.port))
                self.servethread = Thread(target=self.serve_forever)
                self.servethread.setDaemon(True)
                self.servethread.start()
                break 
开发者ID:davidoren,项目名称:CuckooSploit,代码行数:36,代码来源:resultserver.py

示例12: start_server

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import ThreadingTCPServer [as 别名]
def start_server(cls):
        """starting the server to listen"""
        if cls.inst().__server is None:
            try:
                socketserver.ThreadingTCPServer.allow_reuse_address = True
                address = (Options.get_ip(), Options.get_port_sourcetrail_to_vim())
                cls.inst().__server = socketserver.ThreadingTCPServer(address, ConnectionHandler)
                server_thread = threading.Thread(target=cls.inst().__server.serve_forever)
                server_thread.daemon = True
                server_thread.start()
            except socket.error:
                print("Socket needed for Sourcetrail plugin already in use") 
开发者ID:CoatiSoftware,项目名称:vim-sourcetrail,代码行数:14,代码来源:sourcetrail.py

示例13: __init__

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import ThreadingTCPServer [as 别名]
def __init__(self, listener, RequestHandlerClass, bind_and_activate=True):
        """Constructor.  May be extended, do not override."""
        if hasattr(listener, 'getsockname'):
            SocketServer.BaseServer.__init__(self, listener.getsockname(), RequestHandlerClass)
            self.socket = listener
        else:
            SocketServer.ThreadingTCPServer.__init__(self, listener, RequestHandlerClass, bind_and_activate) 
开发者ID:projectarkc,项目名称:arkc-client,代码行数:9,代码来源:proxylib.py

示例14: handle_error

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import ThreadingTCPServer [as 别名]
def handle_error(self, *args):
        """make ThreadingTCPServer happy"""
        exc_info = sys.exc_info()
        error = exc_info and len(exc_info) and exc_info[1]
        if isinstance(error, (socket.error, ssl.SSLError, OpenSSL.SSL.Error)) and len(error.args) > 1 and 'bad write retry' in error.args[1]:
            exc_info = error = None
        else:
            del exc_info, error
            SocketServer.ThreadingTCPServer.handle_error(self, *args) 
开发者ID:projectarkc,项目名称:arkc-client,代码行数:11,代码来源:proxylib.py

示例15: __init__

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import ThreadingTCPServer [as 别名]
def __init__(self, host=DEFAULT_HOST, port=DEFAULT_PORT, handler=LogHandler):
        """Initialize the log receiver

        :param host: The hostname to bind to
        :param port: The port to listen on
        :param handler: The handler to send received messages to

        """
        socketserver.ThreadingTCPServer.__init__(self, (host, port), handler)
        self.abort = 0
        self.timeout = 1
        self.logname = None 
开发者ID:humangeo,项目名称:multilog,代码行数:14,代码来源:receivers.py


注:本文中的SocketServer.ThreadingTCPServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。