-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathObjectServer.py
More file actions
34 lines (30 loc) · 848 Bytes
/
Copy pathObjectServer.py
File metadata and controls
34 lines (30 loc) · 848 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
import socket
import pickle
from twh import ThreeWayHandshake
# from gc import enable
from time import sleep
SERVER_ADDRESS = "127.0.0.1"
SERVER_PORT = 5000
hanler = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
address = (SERVER_ADDRESS, SERVER_PORT)
print(f"server {SERVER_ADDRESS} at port {SERVER_PORT}")
hanler.bind(address)
hanler.listen(1)
def main():
con = (hanler.accept()[0])
connection = False
while connection != True:
print("wating for connection")
# sleep(3)
data = con.recv(4096)
obj = pickle.loads(data)
del data
print("recieved.")
obj.Connection()
print("server side:", obj)
con.sendall(pickle.dumps(obj))
connection = obj.IsConnected()
print("3-way done!!!")
con.close()
# enable()
main()