-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path57Client2.py
More file actions
32 lines (30 loc) · 857 Bytes
/
57Client2.py
File metadata and controls
32 lines (30 loc) · 857 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
32
import socket # Import socket module
import time
import sys
fp = open('57log2.txt', 'a')
s1 = socket.socket() # Create a socket object # Get local machine name
port = 60001 # Reserve a port for your service.
s1.bind(('10.100.0.6', port))
try:
s1.connect(('10.100.0.7', port))
except (socket.error):
s1.close()
execfile('57client2.py')
s1.send("Server 6: Hello server 7!")
f = open('received_file1', 'wb')
fp.write('Start: ')
fp.write(str(int(time.time() * 1000)))
fp.write('\n')
print 'file 2 opened'
while True:
data = s1.recv(4096)
if not data:
break
f.write(data)
f.close()
fp.write('End: ')
fp.write(str(int(time.time() * 1000)))
fp.write('\n')
print ('Successfully got file 2')
s1.close()
print ('Connection to server7 closed')