(address)
| 2 | import time |
| 3 | |
| 4 | def time_server(address): |
| 5 | sock = socket(AF_INET, SOCK_DGRAM) |
| 6 | sock.bind(address) |
| 7 | while True: |
| 8 | msg, addr = sock.recvfrom(8192) |
| 9 | print('Got message from', addr) |
| 10 | resp = time.ctime() |
| 11 | sock.sendto(resp.encode('ascii'), addr) |
| 12 | |
| 13 | if __name__ == '__main__': |
| 14 | time_server(('', 20000)) |