- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
Latest commit
23 lines (21 loc) · 500 Bytes
/
Copy pathclient.py
File metadata and controls
23 lines (21 loc) · 500 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/python
importtime
importsocket
importre
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host=socket.gethostname()
port=12345
s.connect((host, port))
s.send('PING\r')
pre_time=time.time()
recv_line=s.recv(1024)
printrecv_line
matchObj=re.match(r'.* (\d+\.?\d*)', recv_line)
ifmatchObj:
printmatchObj.group(1)
server_time=matchObj.group(1)
delta_time=float(server_time) -pre_time
print'delta time '+str(delta_time)
else:
print'not matched'
s.close