-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.py
More file actions
32 lines (26 loc) · 818 Bytes
/
test.py
File metadata and controls
32 lines (26 loc) · 818 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
30
31
#!/usr/bin/python3
import socket
HOST = '127.0.0.1'
PORT = 2534
def main():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.sendto(bytes('FCWAITING\r\n','UTF-8'), (HOST,PORT))
s.settimeout(10);
try:
(data, address) = s.recvfrom(1024)
print("from address:", address)
print("data:", data)
except ConnectionResetError as e:
print('The server is not currently listening / taking connections:')
print( e)
try:
while data:
(data, address) = s.recvfrom(1024 * 1024)
print("from address:", address)
print("data:", data)
except ConnectionResetError as e:
print('The server is not currently listening / taking connections:')
print( e)
s.close()
if __name__ == '__main__':
main()