Client - Server in Python Sockets
Will this Client + Server Work? CLIENT: import socket client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket.connect('localhost', 8820) while True: msg = input("Send To Server:\n") client_socket.send(msg.encode()) data = client_socket.recv(1024).decode() print("Server Said: " + data) if data == 'Quit': break client_socket.close() SERVER: import socket server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.bind('0.0.0.0', 8820) server_socket.listen(1) print("Listening...") conn_w_client, addr = server_socket.accept() print(f"Connected to {addr}") while True: data = conn_w_client.recv(1024).decode() print("Client Said: " + data) if data == 'Bye': conn_w_client.send('Quit'.encode()) break conn_w_client.send(data.upper().encode()) conn_w_client.close() server_socket.close()