client server communication implemented

This commit is contained in:
2020-06-07 22:55:45 +02:00
parent 28393b1dd4
commit 282c3f3a39
2 changed files with 13 additions and 10 deletions
+7 -6
View File
@@ -3,15 +3,17 @@ import getopt
import sys
import subprocess
def connect(host, port = 5000):
client_socket = socket.socket()
server_IP = "192.168.188.61"
# instantiate
client_socket.connect((host, port)) # connect to the server
def connect(host, port = 5000):
client_socket.connect((host, port))
def disconnect():
client_socket.close() # close the connection
def send(data):
#validate data. should be hex color
client_socket.send(data.encode()) # send message
def helpmenu():
@@ -25,7 +27,6 @@ def visualizer():
print(cava.stdout.readlines())
def main(argv):
try:
opts, args = getopt.getopt(argv, "s:vh")
@@ -39,12 +40,12 @@ def main(argv):
helpmenu()
sys.exit()
elif opt == "-s":
connect(server_IP)
send(arg)
elif opt == "-v":
connect(server_IP)
visualizer()
if __name__ == "__main__":
client_socket = socket.socket()
connect("192.168.188.61")
main(sys.argv[1:])