-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathObjectClient.py
More file actions
35 lines (30 loc) · 891 Bytes
/
ObjectClient.py
File metadata and controls
35 lines (30 loc) · 891 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
33
34
35
import socket
import pickle
from twh import ThreeWayHandshake
# from gc import enable
from time import sleep
SERVER_ADDRES = "127.0.0.1"
SERVER_PORT = 5000
def main():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
address = (SERVER_ADDRES, SERVER_PORT)
conn1 = ThreeWayHandshake()
# print("before", conn1)
sock.connect(address)
conn1.Connection()
while conn1.connected != True:
print("client side:", conn1)
sock.sendall(pickle.dumps(conn1))
if conn1.connected == True:
break
del conn1
data = sock.recv(4096)
sleep(1)
conn1 = pickle.loads(data)
del data
print("client side after response:", conn1)
conn1.Connection()
sleep(3)
print("done.") if conn1.connected == True else print("not done")
# enable()
main()