-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhost_sim.py
More file actions
28 lines (19 loc) · 713 Bytes
/
host_sim.py
File metadata and controls
28 lines (19 loc) · 713 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
import asyncio
from sim_server import SimServer
from not_tcp.host import StreamProxy
class HostSimulator(SimServer, StreamProxy):
# Multiple inheritance is not a *crime*, it's just an abuse of the rules.
# Tax avoidance is not tax evasion!
pass
async def run_server(port):
import sys
import ntcp_http
dut = ntcp_http.NtcpHttpServer()
with HostSimulator(dut, dut.tx, dut.rx) as srv:
server = await asyncio.start_server(
client_connected_cb=srv.client_connected, host="localhost",
port=port)
sys.stderr.write(f"listening on port {port}\n")
await server.serve_forever()
if __name__ == "__main__":
asyncio.run(run_server(3278))