Welcome to Sockets!

Sockets is cool module that lets you run Python code across multiple computers! You can communicate between computers in encoded strings, allowing you to have meaningful multiplayer interaction.This is especially popular for multiplayer games, but is also applicable in many other projects


Getting Started

What do I need to know?

I'd recommend following along with Kyle's starter code (that's me!) which is modified from Rohan's starter code, since that is what I'll be referring to for this tutorial. Download and open the files in Sublime (or pyzo, if you must), and follow along line-by-line with this tutorial.

Additionally, here is his terminal tutorial if you'd like a quick refresher on some terminal navigation we'll be using.

What will I learn?

Great question! On a high level you'll learn the slimmed down version of how devices are connected over the internet and how instructions are communicated. Here is the wikipedia page if you want a more in-depth analysis.

Conceptual Sockets

Have you ever just wanted to mail memes to your relatives across the country? (Yes, that's mail, not email) Well Abhi has, and the process of sockets is preetttty much the same thing (if you squint hard enough)! Here is what happens when Abhi sends his edgy memes:

  1. Abhi finds a quality meme on Carnegie Mellon Memes for Spicy Teens and decides to send it to his extended family.
  2. He prints out the meme and sends it to the post office.
  3. The post office receives the letters,
  4. and sends them to the addresses of his relatives.
  5. Then, the relatives each receive the meme
  6. and laugh uncontrollably

Similarly, sockets is a way for computers to communicate and interact with each other. In python's implementation of sockets, multiple computers (clients) connect to a server, which facilitates (hosts) this communication. A typical sequence of sockets interaction looks like:

  1. A client triggers an action (such as moving).
  2. He/She/They sends a message to the server indicating what happened.
  3. The server receives the message,
  4. and sends the it back to all the clients.
  5. Then, each of the clients receives the message,
  6. and executes the command.

As you can see, there is a lot of communication happening--a lot can go wrong--so make sure you are thorough! With that said, lets get started with the tutorial!

results matching ""

    No results matching ""