pymasep.communication.server

Classes

WaitConnection

Thread used to wait connection and creating the associated socket_handler

WaitAnnouncement

Thread used to wait a client announcement and send the server ip and port

Server

Base class for Server

Module Contents

class pymasep.communication.server.WaitConnection(server, socket_handler_class, socket_handler_args)

Bases: threading.Thread

Thread used to wait connection and creating the associated socket_handler

Parameters:
  • server – the server instance

  • socket_handler_class (Type[Any]) – class used to handle the socket (send, receive)Type[ReceiveHandler]

  • socket_handler_args (tuple) – arguments as tuple to instantiate the SocketHandler class

server

server that is waiting

socket_handler_class

class to handle message

socket_handler_args

arguments for the message handler

_stop_event
stop()

Stop waiting of new connections

run()

main loop of accepting new connections

class pymasep.communication.server.WaitAnnouncement(server)

Bases: threading.Thread

Thread used to wait a client announcement and send the server ip and port Thanks https://pymotw.com/2/socket/multicast.html

Parameters:

server – the server instance

server

server that announces

_stop_listen_annoucement
multicast_group = '224.3.29.71'
server_address = ('', 10000)
stop()

stopping the announcement thread

run()

run the announcement thread

class pymasep.communication.server.Server(ident, max_connection, socket_handler_class, socket_handler_args, host, port, wait_announcement=False, log_level=logging.WARNING)

Bases: pymasep.communication.BaseThreadedCommunication

Base class for Server

Parameters:
  • ident (str) – string id of the client.

  • host (str) – Host to connect.

  • port (int) – Port to connect.

  • max_connection (int) – Max number of connections for the server.

  • socket_handler_class (Type[Any]) – Class used to handle the socket (send, receive). Type[ReceiveHandler]

  • socket_handler_args (tuple) – arguments to instantiate the SocketHandler class

  • wait_announcement (bool) – True if the server is waiting for announcements through Multicast.

  • log_level (Union[str, int]) – Log level messages to log as str or int. Default is logging.WARNING.

max_connection

max number of connection for the server

wait_connection_thread

thread for handling new connection

__del__()

Delete the instance. Close the socket and stop the thread that wait connection and the thread that wait the announcement

wait_connection()

start the wait connection thread

stop_wait_connection()

stop the wait connection thread

wait_announcement()

start the wait announcement thread

stop_wait_announcement()

stop the wait announcement thread