jsb-netgame/demo.py

17 lines
302 B
Python
Raw Normal View History

2024-01-27 16:56:24 +00:00
import network, sys, time
sock = network.Sock()
port = int(sys.argv[2])
if sys.argv[1] == "s":
sock.listen(("0.0.0.0", port))
while True:
2024-02-03 17:57:23 +00:00
for d, a in sock.get():
2024-01-27 16:56:24 +00:00
print(d, a)
time.sleep(0.1)
elif sys.argv[1] == "c":
while True:
2024-02-17 17:05:21 +00:00
sock.send(time.time(), (sys.argv[3], port))
2024-01-27 16:56:24 +00:00
time.sleep(1)