This repository has been archived on 2026-05-29. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Programmierprojekt/documents/docs/blog/09-03-26_Network.md
T

2.5 KiB
Raw Blame History

Table of Contents

Basics

Formal concepts of networking

Whenever you want to access the same data on different devices without carrying it (the data) from device to device, with, lets say, a thumb drive, you have multiple options for achieving this.

Peer To Peer Versus Client-Server Architecture

Peer to Peer enables users to share content (files, messages, ...). While it does not rely on a central server, it comes with the big trade-of that the device storing the data you want to access has to be reachable and online. Today Peer to Peer is still widely used with VoIP and decentralized networks for censorship-resistant transactions formaly known as the blockchain.

The Client-Server model evolved into the sophisticated "web-services" we know and use daily. One central powerful computer (the server) stores data and allows external devices (clients) to access it.

For our course "Programmierprojekt" we are required to use the Client-Server model.

The Language of the Network

To communicate over the network, we first need to establish a few rules.

If we look at the real world, language also follows certain rules:

  • Grammar
  • Meaning of Words

In computer science, these rules are known as a "protocol." Everyone must follow these rules, because if not, the program we want to communicate with wouldnt understand us, or in the worst case, misunderstand us.

For our network, weve decided to build upon the Post Office Protocol (POP) version 3. It follows the request-response model, is synchronous, and meets our requirements.

An example of a request and response (for our game) might look like this:

  1. Request

    GET_DELTA 42
    
  2. Response

    +OK
    PLAYER_FOLDED playerId=3
    POT 240
    NEXT_TURN playerId=1
    WHISPER from=player2 msg="hey"
    CHAT_LOBBY player3="hello"
    .
    

The client requests the occurred actions since the 42nd state.

The server responds with all the actions other players have made and the messages the client has received.