2018-04-19 22:25:45 +01:00
|
|
|
"""
|
2018-04-26 00:33:58 +01:00
|
|
|
Defines core server for handling TCP connections.
|
2018-04-19 22:25:45 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
import SocketServer
|
|
|
|
|
2018-05-01 18:40:25 +01:00
|
|
|
from core.emulator.coreemu import CoreEmu
|
2018-04-19 22:25:45 +01:00
|
|
|
|
|
|
|
|
2018-04-26 00:33:58 +01:00
|
|
|
class CoreServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
|
2018-04-19 22:25:45 +01:00
|
|
|
"""
|
|
|
|
TCP server class, manages sessions and spawns request handlers for
|
|
|
|
incoming connections.
|
|
|
|
"""
|
|
|
|
daemon_threads = True
|
|
|
|
allow_reuse_address = True
|
|
|
|
|
|
|
|
def __init__(self, server_address, handler_class, config=None):
|
|
|
|
"""
|
|
|
|
Server class initialization takes configuration data and calls
|
|
|
|
the SocketServer constructor
|
|
|
|
|
|
|
|
:param tuple[str, int] server_address: server host and port to use
|
|
|
|
:param class handler_class: request handler
|
|
|
|
:param dict config: configuration setting
|
|
|
|
:return:
|
|
|
|
"""
|
2018-04-21 01:00:47 +01:00
|
|
|
self.coreemu = CoreEmu(config)
|
2018-04-19 22:25:45 +01:00
|
|
|
self.config = config
|
|
|
|
SocketServer.TCPServer.__init__(self, server_address, handler_class)
|