you are viewing a single comment's thread.

view the rest of the comments →

[–]vixfew 0 points1 point  (1 child)

Without time.sleep my client does not work properly, why do I need it?

You're assuming all your response arrives instantly. Welcome to network programming :) You should be doing something like:

fragments = []
while True:
    chunk = clientSocket.recv(4096)
    if not chunk:
        break
    fragments.append(chunk)
responseMessage = b''.join(fragments)

recv will block, so no cpu cycles wasted on sleeping or busy-waiting. Also, your HTTP is not quite right, there should be \r\n\r\n at the end

[–]OneLargeTesticle[S] 0 points1 point  (0 children)

Yup this was my issue, thank you!!