Hlep!
Documentation:
For the official Python documentation, click here.
I'm sending a message but the server isn't receiving it!
You probably forgot to encode your string message using .encode()
! Or maybe you really just forgot to send it. Make sure you have code that looks something like data.server.send(msg.encode())
I sent the message and the server received it, but didn't send it back!
Most likely, you forgot to include the message delineator. (We used "\n"
for this) This means that the server is still waiting on the delineator to complete the message, so it won't send anything until it gets the delineator.
There are a bunch of stacked up messages in the server queue, but they aren't sending!
You probably forgot to include the message delineator. (We used "\n"
for this). See above.
My messages are going through, but it says "failed"!
This means that somewhere your program could not read the instructions you sent. Most likely, you misformatted the string instruction when you sent it in the client side. Remember, there is a strict format for your string (ours is "instruction detail1 detail2 . . . \n"
) where each is separated by a space) So if you didn't follow that exact format, your instructions won't process correctly.
Alternatively, you could have used the delineator as part of your instruction (like if you put a newline in body of the message you sent), or you may have just crashed inside your timerfired
loop.
Everything is working fine, it just takes a while to process the directions!
Since only one instruction can be dealt with each timerFired
, simply lower data.timerdelay
so that this happens more frequently. There are other solutions too, but that's up to you to find!
Terminal says ...
Traceback (most recent call last):
File "game_server.py", line 10, in <module>
server.bind((HOST,PORT))
OSError: [Errno 48] Address already in use
... when I try to run dots_server.py
Simply wait a bit, and the port will open up again. Alternatively, you can switch ports, so if you were using PORT = 50001
, change it to PORT = 50003
or something. Make sure to do it on both the client and server files.
My code in timerFired
is disgustingly long!
Totally normal! Try writing some well-chosen helper functions, or try an object-oriented approach (like I did!)
What is my IP Address?
See Quick Tips! You can Google it. Just please don't Bing it. Please.
Why is 'queue' not spelled 'q' or 'que' or 'kew'?
Blame the French