openwpm.socket_interface module

class openwpm.socket_interface.ClientSocket(serialization='json', verbose=False)[source]

Bases: object

A client socket for sending messages

close()[source]
connect(host, port)[source]
send(msg)[source]

Sends an arbitrary python object to the connected socket. Serializes using dill if not string, and prepends msg len (4-bytes) and serialization type (1-byte).

class openwpm.socket_interface.ServerSocket(name=None, verbose=False)[source]

Bases: object

A server socket to receive and process string messages from client sockets to a central queue

close()[source]
receive_msg(client, msglen)[source]
start_accepting()[source]

Start the listener thread

async openwpm.socket_interface.get_message_from_reader(reader: StreamReader) Any[source]

Reads a message from the StreamReader To safely use this method, you should guard against the exception like this:

try:
    record: Tuple[str, Any] = await get_message_from_reader(reader)
except IncompleteReadError as e:
    print("The underlying socket closed", repr(e))
Raises:

IncompleteReadError: If the underlying socket is closed

openwpm.socket_interface.main()[source]