From 036cc9445b8a15c282c095c6631215fec2a68520 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Couturier?= Date: Mon, 12 Jul 2021 11:45:41 +0200 Subject: [PATCH 1/1] new --- measure_energy_iot/buffer.py | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 measure_energy_iot/buffer.py diff --git a/measure_energy_iot/buffer.py b/measure_energy_iot/buffer.py new file mode 100644 index 0000000..373a777 --- /dev/null +++ b/measure_energy_iot/buffer.py @@ -0,0 +1,42 @@ +class Buffer: + def __init__(self,s): + '''Buffer a pre-created socket. + ''' + self.sock = s + self.buffer = b'' + + def get_bytes(self,n): + '''Read exactly n bytes from the buffered socket. + Return remaining buffer if