|
@@ -182,38 +182,47 @@ class ConnHandlerEcho(ConnHandler):
|
|
|
|
|
|
class Server(object):
|
|
class Server(object):
|
|
"""
|
|
"""
|
|
- Server opens either an unix or an inet connection. for every client which connects a new ClientHandler class is created.
|
|
+ Server opens either an unix or an inet connection. For every new client
|
|
|
|
+ a new ClientHandler object is created.
|
|
|
|
+ _string_ **host** and _int_ **port** are the filename, hostname or ip
|
|
|
|
+ address and the port respectively on which the connection will be opened.
|
|
|
|
+ If you make an AF_UNIX socket, port is ignored so simply pass None.
|
|
|
|
+ _object_ **handler_class** is the class (not an object of the class) used
|
|
|
|
+ for making connection handlers.
|
|
|
|
+ _dict_ **handler_kwargs** is a dict which will be passed as keyword
|
|
|
|
+ argumetns to the __init__ function of handler_class when creating a new
|
|
|
|
+ connection handler. Default is an emtpy dict.
|
|
|
|
+ _string_ **af_family** specifies the AF_FAMILY socket type, valid options
|
|
|
|
+ are: "AF_INET" for a inet socket and "AF_UNIX" for a unix (file) socket.
|
|
|
|
+ Default is "AF_INET".
|
|
|
|
+ _bool_ **log_ip** specifies wether the ip address of the server/client is logged.
|
|
|
|
+ Default is False.
|
|
|
|
+ _int_ **max_allowed_clients** specifies the maximum amount of clients
|
|
|
|
+ connected to the server at once. Default is 5 (for now. this will change
|
|
|
|
+ in the future).
|
|
"""
|
|
"""
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ self.exit_event = False
|
|
def __init__(self,
|
|
def __init__(self,
|
|
host,
|
|
host,
|
|
- port=None,
|
|
+ port,
|
|
|
|
+ handler_class,
|
|
|
|
+ handler_kwargs={},
|
|
af_family="AF_INET",
|
|
af_family="AF_INET",
|
|
log_ip=False,
|
|
log_ip=False,
|
|
max_allowed_clients=5,
|
|
max_allowed_clients=5,
|
|
- handler_class=None,
|
|
|
|
- handler_kwargs={},
|
|
|
|
):
|
|
):
|
|
super(Server, self).__init__()
|
|
super(Server, self).__init__()
|
|
-
|
|
|
|
-
|
|
|
|
- self.exit_event = False
|
|
|
|
-
|
|
|
|
self.host = host
|
|
self.host = host
|
|
-
|
|
|
|
self.port = port
|
|
self.port = port
|
|
-
|
|
+ self.handler_class = handler_class
|
|
|
|
+ self.handler_kwargs = handler_kwargs
|
|
self.af_family = af_family
|
|
self.af_family = af_family
|
|
-
|
|
|
|
self.log_ip = log_ip
|
|
self.log_ip = log_ip
|
|
-
|
|
|
|
self.max_allowed_clients = max_allowed_clients
|
|
self.max_allowed_clients = max_allowed_clients
|
|
-
|
|
|
|
- self.handler_class = handler_class
|
|
|
|
-
|
|
|
|
- self.handler_kwargs = handler_kwargs
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
self.socket = None
|
|
self.socket = None
|
|
|
|
|
|
|
|
|