pymasep.communication.server ============================ .. py:module:: pymasep.communication.server Classes ------- .. autoapisummary:: pymasep.communication.server.WaitConnection pymasep.communication.server.WaitAnnouncement pymasep.communication.server.Server Module Contents --------------- .. py:class:: WaitConnection(server, socket_handler_class, socket_handler_args) Bases: :py:obj:`threading.Thread` Thread used to wait connection and creating the associated socket_handler :param server: the server instance :param socket_handler_class: class used to handle the socket (send, receive)Type[ReceiveHandler] :param socket_handler_args: arguments as tuple to instantiate the SocketHandler class .. py:attribute:: server server that is waiting .. py:attribute:: socket_handler_class class to handle message .. py:attribute:: socket_handler_args arguments for the message handler .. py:attribute:: _stop_event .. py:method:: stop() Stop waiting of new connections .. py:method:: run() main loop of accepting new connections .. py:class:: WaitAnnouncement(server) Bases: :py:obj:`threading.Thread` Thread used to wait a client announcement and send the server ip and port Thanks https://pymotw.com/2/socket/multicast.html :param server: the server instance .. py:attribute:: server server that announces .. py:attribute:: _stop_listen_annoucement .. py:attribute:: multicast_group :value: '224.3.29.71' .. py:attribute:: server_address :value: ('', 10000) .. py:method:: stop() stopping the announcement thread .. py:method:: run() run the announcement thread .. py:class:: Server(ident, max_connection, socket_handler_class, socket_handler_args, host, port, wait_announcement = False, log_level = logging.WARNING) Bases: :py:obj:`pymasep.communication.BaseThreadedCommunication` Base class for Server :param ident: string id of the client. :param host: Host to connect. :param port: Port to connect. :param max_connection: Max number of connections for the server. :param socket_handler_class: Class used to handle the socket (send, receive). Type[ReceiveHandler] :param socket_handler_args: arguments to instantiate the SocketHandler class :param wait_announcement: True if the server is waiting for announcements through Multicast. :param log_level: Log level messages to log as str or int. Default is logging.WARNING. .. py:attribute:: max_connection max number of connection for the server .. py:attribute:: wait_connection_thread thread for handling new connection .. py:method:: __del__() Delete the instance. Close the socket and stop the thread that wait connection and the thread that wait the announcement .. py:method:: wait_connection() start the wait connection thread .. py:method:: stop_wait_connection() stop the wait connection thread .. py:method:: wait_announcement() start the wait announcement thread .. py:method:: stop_wait_announcement() stop the wait announcement thread