Jim's
Tutorials

Spring 2018
course
site

This was really interesting. I had trouble getting the right "side" to take a user input (also had trouble telling who should be doing what)... sort of like getting your left and right hands confused. I kept making the server do things I'd meant for the client end to do. Eventually got it straightened out. It helped to read Socket Programming HowTo :https://docs.python.org/2/howto/sockets.html and Socket Programming in Python: https://www.geeksforgeeks.org/socket-programming-python/.

So I made a conversation between client and server, where client asks if one likes blue or green to deliver a fortune. I did this to prep for making the tic-tac-toe game.

python server.py
Socket successfully created
socket binded to 12345
socket is listening
Got connection from ('127.0.0.1', 58543)
python client.py
Do you like blue or green? Ill tell you your fortune (b/g)

..and you select b or g (for blue or green) and it spits out the fortune that is sent to the server, except I made it be REVERSED on the server side and be sent back (usually it says "you will marry a rich daughter"):

python client.py
Do you like blue or green? Ill tell you your fortune (b/g)g
rethguad hcir a yrram lliw uoy
https://cs.marlboro.college /cours /spring2018 /jims_tutorials /web_tech /socket stuff
last modified Sun November 10 2024 9:00 pm

attachments [paper clip]

  last modified size
TXT client.py Sun Nov 10 2024 09:00 pm 657B
TXT function.py Sun Nov 10 2024 09:00 pm 801B
TXT server.py Sun Nov 10 2024 09:00 pm 1.2K