-
Notifications
You must be signed in to change notification settings - Fork 0
/
simpsvsck.py
42 lines (32 loc) · 1.17 KB
/
simpsvsck.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
import json
import socket, authproc
HOST = '127.0.0.1'
PORT = 65432
# Server
def servconn(host, ports):
# Create socket object, omits Close()
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
# A pair (host, port) is used
# for the AF_INET address family
sock.bind((host,ports))
# Open Port
sock.listen()
# Blocks and waits for incomming connection.
conn, addr = sock.accept()
# Print successful connection
print('Connection Established: ', addr)
while True:
# 1024 bytes buffer
data = conn.recv(1024)
# If data not present close connection
if not data:
break
else:
#ukey = data.decode('utf-8').strip()
ukey = json.loads(data.decode('utf-8').strip())
print(ukey)
#authproc.accesscomm_record(authproc.establish_accesscomm(),ukey[0],authproc.hash_key(authproc.zest_key(), ukey[1]))
# Send data to socket
conn.sendall(data)
# Start Server
servconn(HOST, PORT)