- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
Latest commit
22 lines (20 loc) · 479 Bytes
/
Copy pathserver.py
File metadata and controls
22 lines (20 loc) · 479 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/python
importtime
importsocket
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
host=socket.gethostname()
port=12345
s.bind((host, port))
s.listen(5)
whileTrue:
c, addr=s.accept()
print'Got connection from', addr
whileTrue:
recv_line=c.recv(1024)
printrecv_line
ifrecv_line=='PING\r':
time_s=str(time.time())
c.send('PONG '+time_s)
break
c.close()