# ad-tech1009/networkprotocol architecture

> Architecture diagram of the GitHub repository ad-tech1009/networkprotocol, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ad-tech1009/networkprotocol
- Repository: https://github.com/ad-tech1009/networkprotocol

## Overview

##### Project type and purpose
- This is a network-programming example repository providing two implementations of a TCP client/server pair: one in C++ using the Windows Sockets API (Winsock) under the `WIndows/` directory, and one in plain C using BSD-style sockets under the `linux/` directory.
- Its purpose is educational: to demonstrate socket initialization, connection setup (bind, listen, accept), data exchange, and cleanup on two different platforms.

##### File structure
- Top level:
- `.gitignore` – standard VCS ignore file.
- `README.md` – overarching project description and Windows build instructions.
- `WIndows/` – contains `server.cpp` and `client.cpp`: the Winsock2-based examples.
- `linux/` – contains `README.md` plus `httpserv.c`, `tcp_client.c`, and `tcp_server.c`: Linux/BSD sockets examples.
- Each platform folder is a self-contained demo with its own source files and build instructions.

##### README for additional insights
- The main README focuses on the Windows examples, dependencies (Ws2_32.lib), and step-by-step build/run instructions.
- The Linux subfolder’s README (not shown here) presumably describes how to compile the C examples with `gcc` and run them.

##### Elements
- Clear labels: “Win Server”, “Win Client”, “Linux Server”, “Linux Client”, “Network”.
- From Client to Server: TCP handshake (SYN, etc.)
- Rectangles for application components (source code).

## Diagram (Mermaid)

```mermaid
flowchart LR
    subgraph "Windows"
        direction TB
        WinClient["Win Client\nclient.cpp\n(Winsock2)"]:::windows
        WinStack[("Windows\nTCP/IP Stack")]:::os
        WinServer["Win Server\nserver.cpp\n(Winsock2)"]:::windows
    end

    subgraph "Network"
        Net[("Network\n(LAN/WAN)")]:::network
    end

    subgraph "Linux"
        direction TB
        LinClient["Linux Client\ntcp_client.c\n(BSD sockets)"]:::linux
        LinStack[("Linux\nTCP/IP Stack")]:::os
        LinServer["Linux Server\ntcp_server.c\n(BSD sockets)"]:::linux
        HTTPServ["Linux HTTP Server\nhttpserv.c\n(BSD sockets)"]:::linux
    end

    WinClient -->|"create socket\nconnect\nTCP handshake"| WinStack
    WinStack -->|"SYN"| Net
    Net -->|"SYN-ACK"| WinStack
    WinStack -->|"accept\nbind\nlisten"| WinServer

    LinClient -->|"create socket\nconnect\nTCP handshake"| LinStack
    LinStack -->|"SYN"| Net
    Net -->|"SYN-ACK"| LinStack
    LinStack -->|"accept\nbind\nlisten"| LinServer

    WinServer ---|"FIN/ACK teardown"| WinStack
    WinStack ---|"FIN/ACK teardown"| Net
    Net ---|"FIN/ACK teardown"| LinStack
    LinStack ---|"FIN/ACK teardown"| LinServer

    WinClient <-->|"Data exchange\n(send/recv)"| WinServer
    LinClient <-->|"Data exchange\n(send/recv)"| LinServer

    click WinServer "https://github.com/ad-tech1009/networkprotocol/blob/main/WIndows/server.cpp"
    click WinClient "https://github.com/ad-tech1009/networkprotocol/blob/main/WIndows/client.cpp"
    click LinServer "https://github.com/ad-tech1009/networkprotocol/blob/main/linux/tcp_server.c"
    click LinClient "https://github.com/ad-tech1009/networkprotocol/blob/main/linux/tcp_client.c"
    click HTTPServ "https://github.com/ad-tech1009/networkprotocol/blob/main/linux/httpserv.c"
    click Net "https://github.com/ad-tech1009/networkprotocol/blob/main/README.md"
    click LinClient "https://github.com/ad-tech1009/networkprotocol/blob/main/linux/README.md"

    classDef windows fill:#add8e6,stroke:#000
    classDef linux fill:#90ee90,stroke:#000
    classDef os fill:#ffffe0,stroke:#000
    classDef network fill:#d3d3d3,stroke:#000
```
