def __init__(self, port=9025, logfile=None, parser=None): self.port = port self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.file = None self.conn = None self.envelopes = [] self.hostname = socket.gethostname() self._client = None self._callback = None self._reset() while 1: try: self.socket.bind(("", self.port)) break except socket.error as msg: print("couldn't bind port", self.port, " - ", msg, "retrying...", file=sys.stderr) scheduler.sleep(5) self.socket.listen(50) self.conversation = None self.logfile = logfile self.parser = parser
def __init__ (self, port=9025, logfile=None, parser=None): self.port = port self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.file = None self.conn = None self.envelopes = [] self.hostname = socket.gethostname() self._client = None self._callback = None self._reset() while 1: try: self.socket.bind(("", self.port)) break except socket.error as msg: print ("couldn't bind port",self.port," - ",msg,"retrying...", file=sys.stderr) scheduler.sleep(5) self.socket.listen(50) self.conversation = None self.logfile = logfile self.parser = parser
def _get_hostname(): global _HOSTNAME if _HOSTNAME is None: _HOSTNAME = socket.gethostname() return _HOSTNAME
def hostname(self): """Returns the client hosts name.""" return socket.gethostname()