當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。