-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
50 lines (37 loc) · 1.14 KB
/
client.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import socket, os
server_address = ('localhost', 29000)
size = 32769
makeSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
makeSocket.connect(server_address)
judul = raw_input()
titleSplit=judul.split()#membagi isi string yang berspasi menjadi array of string
if titleSplit[0]=='unggah':
title = titleSplit[1]
count = 2
while True:
if count==len(titleSplit): break
else:
title += " " + titleSplit[count]
count += 1
print title
makeSocket.send(title)
try:
isi = os.path.abspath(title)
print isi
try:
f = open(isi,'rb')
#while True:
# fsend = f.read(size)
# if not fsend: break;
# makeSocket.sendall(fsend)
for send in f:
makeSocket.sendall(send)
#print cekEnd
except: fread.close()
finally: fread.close()
try:
message = makeSocket.recv(size)
if message: print message
except: makeSocket.close()
except: makeSocket.close()
makeSocket.close()