-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlisten.py
34 lines (32 loc) · 880 Bytes
/
listen.py
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
30
31
32
33
34
import socket
sock = socket.socket()
sock.bind(('', 3097))
sock.listen(1)
conn, addr = sock.accept()
while True:
try:
data = conn.recv(2048)
if not data:
print('NO DATA')
break
else:
print(data)
d = data.decode('utf8')
# n = d.replace(r'\r\n', '')[len(d)-4:]
parse = d.split('@')
# print(parse)
n = parse[-2]
print(f'{n=}')
conn.send(f'RondServer@AckPassing@{n}@$'.encode())
if b'@Pong@' in data:
conn.send(b'RondServer@[email protected]@$')
# conn.send(data.upper())
# conn.send(b'hello')
# conn.send(b'RondServer@GetInfo@office@$')
except KeyboardInterrupt:
i = input('input:')
if i:
conn.send(i.encode())
else:
break
conn.close()