def __init__(self, name, *p, **k): # base ServerGenericSocket.__init__(self, name, *p, **k) # socket-hostname self.socketHostname = Config().get(name, 'host').strip() if self.socketHostname.lower() == 'auto': self.socketHostname = socket.gethostname() # socket-port self.socketPort = int(Config().get(name, 'port').strip())
class ServerInetSocket(ServerGenericSocket): """ -------------------------------------------------------------------- """ """ __init__ """ """ -------------------------------------------------------------------- """ def __init__(self, name, *p, **k): # base ServerGenericSocket.__init__(self, name, *p, **k) # socket-hostname self.socketHostname = Config().get(name, 'host').strip() if self.socketHostname.lower() == 'auto': self.socketHostname = socket.gethostname() # socket-port self.socketPort = int(Config().get(name, 'port').strip()) """ -------------------------------------------------------------------- """ """ status """ """ -------------------------------------------------------------------- """ def status(self): data = {} data['clientsServed'] = str(self.clientsServed) data['host'] = str(self.socketHostname) data['port'] = str(self.socketPort) return data """ -------------------------------------------------------------------- """ """ getServerSocket """ """ -------------------------------------------------------------------- """ def getServerSocket(self): # log self.logger.info("create server-socket... (%s:%d)" % (str(self.socketHostname), self.socketPort)) # create socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # bind the socket sock.bind((self.socketHostname, self.socketPort)) # return the socket return sock """ -------------------------------------------------------------------- """ """ cleanupServerSocket """ """ -------------------------------------------------------------------- """ def cleanupServerSocket(self): pass