-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.py
More file actions
32 lines (27 loc) · 846 Bytes
/
client.py
File metadata and controls
32 lines (27 loc) · 846 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, json
import time, sys
import random
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = sys.argv[1]
port = int(sys.argv[2])
s.connect((host, port))
# s.send(x.strip().encode())
x = input("What do you want to Do? 1. view 2. edit 3. see all updated 4. exit\n")
while( x != 4):
if (x == 1):
s.send("read")
data = s.recv(2048)
data_arr = json.dumps(data)
print(data_arr.replace("\\", ""))
if (x == 2):
s.send("write")
data = raw_input("Please enter what you want to update\n")
s.send(data.encode())
if (x == 3):
s.send("update")
data = s.recv(4098)
data_arr = json.dumps(data)
print(data_arr.replace("\\", ""))
x = input("What do you want to Do? 1. view 2. edit 3. see all updated 4. exit\n")
s.send("4")
s.close()