def main():
# You can use print statements as follows for debugging, they'll be visible when running tests.
print("Logs from your program will appear here!")
server_socket = socket.create_server(("localhost", 6379), reuse_port=True)
server_socket.listen(6379) # listen on the port
while True:
client_socket,address = server_socket.accept() # wait for client request and accept the connection
while True:
data_input = client_socket.recv(2048) # read the data from the client
if not data_input:
break
client_socket.send(b"+PONG\r\n") # reply to the client with pong (hardcoded for now)
if not data_input:
break
client_socket.close()
I submitted this code and it works but it looks like utter garbage and I know that im writing some redudant logic somewhere but im unable to figure out what it is because I dont know enough yet is this really the right way to read multiple messages from one client socket?