The client/server code is fine.
I guess the protocol spec is the text that you have below? I don't think that this is specific enough - if that's what you were given and then asked to write a client/server app, you'd have lots of questions, like "what does 'proper message recieved' mean?".
I think we should have read some RFC's to see what protocol specs looked like.
Here's a sample test output with the custom server:
>>> python test_server.py
Socket successfully created
socket binded to 12345
socket is listening
what would you like your response to be?
why hello there
uncomfirmed
what would you like your response to be?
hello, let's play a game of blackjack
confirmed
what would you like your response to be?
got some cards for you
uncomfirmed
what would you like your response to be?
you were dealt the king of kinds and the queen of queens
confirmed
what would you like your response to be?
would you like to do some hitting or standing?
stand
what would you like your response to be?
you sure?
h
what would you like your response to be?
oh lets deal another card
s
what would you like your response to be?
sweet - dealer had way too many points - you win!
Here's a sample output from the client side with the non-responsive server:
>>> python client.py
server not responsive, closing connection
Traceback (most recent call last):
File "client.py", line 27, in <module>
s.send("uncomfirmed")
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 174, in _dummy
raise error(EBADF, 'Bad file descriptor')
socket.error: [Errno 9] Bad file descriptor
Here's a sample functioning output with the main server:
>>> python client.py
hello, let's play a game of blackjack
you were dealt the 3 of Diamonds, and Ace of Diamonds, your score is 14
would you like to hit or stand? (h or s)
hit
please print a valid input, (h or s)
h
you were dealt the Jack of Clubs, your score is 24, would you like to hit or stand?
stand
please print a valid input, (h or s)
s
computer busted, player wins
last modified | size | ||
card.py | Sat Dec 21 2024 06:37 pm | 2.1K | |
client.py | Sat Dec 21 2024 06:37 pm | 1.1K | |
deck.py | Sat Dec 21 2024 06:37 pm | 773B | |
game.py | Sat Dec 21 2024 06:37 pm | 4.3K | |
hand.py | Sat Dec 21 2024 06:37 pm | 980B | |
server.py | Sat Dec 21 2024 06:37 pm | 1.4K | |
server_thread.py | Sat Dec 21 2024 06:37 pm | 748B | |
test_server.py | Sat Dec 21 2024 06:37 pm | 795B | |
unresponsive_server.py | Sat Dec 21 2024 06:37 pm | 573B |