Skip to content

Echo32¤

An example of a 32-bit echo server.

Echo32 is the 32-bit server class and Echo64 is the 64-bit client class. These Echo classes do not actually communicate with a library. The point of these Echo classes is to show that a Python data type in a 64-bit process appears as the same data type in the 32-bit process and vice versa. (provided that the data type is pickleable.)

Echo32 ¤

Echo32(host, port)

Bases: Server32

Example that shows Python data types are preserved between Echo32 and Echo64.

Parameters:

Name Type Description Default
host str

The IP address (or hostname) to use for the server.

required
port int

The port to open for the server.

required
Source code in src/msl/examples/loadlib/echo32.py
21
22
23
24
25
26
27
28
29
30
31
def __init__(self, host: str, port: int) -> None:
    """Example that shows Python data types are preserved between [Echo32][] and [Echo64][].

    Args:
        host: The IP address (or hostname) to use for the server.
        port: The port to open for the server.
    """
    # even though this is a *echo* class that does not call a library
    # we still need to provide a library file that exists. Use the C++ library.
    path = Path(__file__).parent / "cpp_lib32"
    super().__init__(path, "cdll", host, port)

received_data staticmethod ¤

received_data(*args, **kwargs)

Process a request from the Echo64.send_data method.

Parameters:

Name Type Description Default
args Any

The arguments.

()
kwargs Any

The keyword arguments.

{}

Returns:

Type Description
tuple[tuple[Any, ...], dict[str, Any]]

The args and kwargs that were received.

Source code in src/msl/examples/loadlib/echo32.py
33
34
35
36
37
38
39
40
41
42
43
44
@staticmethod
def received_data(*args: Any, **kwargs: Any) -> tuple[tuple[Any, ...], dict[str, Any]]:
    """Process a request from the [Echo64.send_data][msl.examples.loadlib.echo64.Echo64.send_data] method.

    Args:
        args: The arguments.
        kwargs: The keyword arguments.

    Returns:
        The `args` and `kwargs` that were received.
    """
    return args, kwargs