The networking module

The networking module contains various modules pertaining to setting up system components in a networked fashion (e.g., through server and client sockets).

The Connection class

class pyamp.networking.Connection(server, conn, addr, logger=None)

The Connection class handles receiving data from a single socket connected to a server.

This class implements the pyamp.processes.Thread and the pyamp.logging.Loggable interfaces.

  • server – The server object
  • conn – The socket connection
  • addr – The address for this connection
  • logger – The LogData or Logger object for this class
onCycle(_i)

Called for each cycle of the pyamp.processes.Thread.

  • i – The current cycle number
onException(_e, traceback)

Called in the event of an exception.

  • e – The exception
  • traceback – The traceback
onShutdown()

Called in the event that the pyamp.processes.Thread is shutdown.

The Server class

class pyamp.networking.Server(connectionClass, port, host='', logger=None)

The Server class handles creating a server on a specific host and port. It also handles multiple connections to the server while being able to receive data from any of those connections.

This class implements the pyamp.processes.Thread and pyamp.logging.Loggable interfaces.

  • connectionClass – The class used to handle each connection
  • port – The server port number
  • host – The server host
  • logger – The LogData or Logger for this class
closeConnection(addr)

Close an open connection.

  • addr – The address for the connection to close
onCycle(_i)

Called for every cycle of the pyamp.processes.Thread.

  • i – The current cycle number
onReceive(addr, data)

Called in the event that data is received.

  • addr – The address of the connection where the data originated
  • data – The data that was received
onShutdown()

Called in the event that the pyamp.processes.Thread is shutdown.

onStart()

Called when the pyamp.processes.Thread is started.

openConnection(conn, addr)

Handle the newly opened connection.

  • conn – The socket object for the connection
  • addr – The address for the connection

Table Of Contents

This Page