-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreceiver.py
More file actions
29 lines (21 loc) · 712 Bytes
/
receiver.py
File metadata and controls
29 lines (21 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import asyncio
from QUIC import QUIC_CONNECTION
BIND_ADDRESS = '0.0.0.0'
LISTEN_PORT = 9191
async def accept_data() -> None:
conn = QUIC_CONNECTION()
conn.listen_to(BIND_ADDRESS, LISTEN_PORT)
while True:
data_batch = await conn.receive_data()
if data_batch is None:
break
"""
taking the data_batch and writing each data chunk to a separate file
"""
for index, data_chunk in enumerate(data_batch):
file_name = f"output_f{index}.txt"
with open(file_name, "wb") as output_file:
output_file.write(data_chunk)
conn.end_communication()
if __name__ == '__main__':
asyncio.run(accept_data())