client server communication implemented
This commit is contained in:
+7
-6
@@ -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:])
|
||||
Reference in New Issue
Block a user