MCPcopy Create free account
hub / github.com/apache/singa / receive_int

Function receive_int

examples/hfl/src/proto/utils.py:64–77  ·  view source on GitHub ↗

Receive an integer from socket. Args: conn (socket.socket): Socket connection. pack_format (str, optional): Pack format. Defaults to "Q", which means unsigned long long. Returns: int: Received integer.

(conn: socket.socket, pack_format: str = "Q")

Source from the content-addressed store, hash-verified

62
63
64def receive_int(conn: socket.socket, pack_format: str = "Q") -> int:
65 """Receive an integer from socket.
66
67 Args:
68 conn (socket.socket): Socket connection.
69 pack_format (str, optional): Pack format. Defaults to "Q", which means unsigned long long.
70
71 Returns:
72 int: Received integer.
73 """
74 buffer_size = struct.Struct(pack_format).size
75 data = receive_all(conn, buffer_size)
76 (data,) = struct.unpack(f"!{pack_format}", data)
77 return data
78
79
80def send_message(conn: socket.socket, data: Message, pack_format: str = "Q") -> None:

Callers 1

receive_messageFunction · 0.85

Calls 1

receive_allFunction · 0.85

Tested by

no test coverage detected