-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
35 lines (29 loc) · 906 Bytes
/
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
""" Simple client for MDB access server connection
"""
import socket
import logging
import msgpack
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)
def client(msg):
""" Simple Client
"""
server_address = ('localhost', 8090)
with socket.socket(socket.AF_INET,
socket.SOCK_STREAM,
socket.IPPROTO_TCP) as sock:
sock.connect(server_address)
response = bytes()
sock.send(msg)
response = sock.recv(64)
logging.debug("RAW Response %s", response)
return response, sock
def main():
""" Main Entry Point
"""
while True:
msg = input("DBNumber: ")
raw_response, sock = client(str.encode(msg))
response = msgpack.unpackb(raw_response, raw=False)
logging.info("Response returned: %s", response)
if __name__ == '__main__':
main()