How to Write a Socket Server from Start to Finish!

Опубликовано: 06 Март 2024
на канале: hoff._world
4,271
224

We're writing a publisher subscriber socket server using thread pools and epoll for load balancing. Watch me chill in my thread pool :D

epoll man page: https://man7.org/linux/man-pages/man7...
pthread man page: https://man7.org/linux/man-pages/man7...
socket man page: https://man7.org/linux/man-pages/man2...

Implementing the Net Protocol:    • Implementing a Network Protocol in C ...  
Writing Rolexhound:    • How to Write a Linux Daemon from Star...  

Project Folder: https://hoff.industries/files/flexsrv...

Editor: Kate (xoxo KDE)
Colours: Custom (based on Monokai tho)
LSP Server: clangd

Chapters:
00:00 - Teaser
00:08 - Intro and Overview
01:30 - High Level Architecture
10:05 - Known Quirks and Issues
13:19 - Defining Data Structures
18:38 - Writing Helper Functions
21:45 - Writing a Table Search Function
29:13 - Writing the Main Function (finally lmao)
33:01 - Allocating our Thread Pool!
37:07 - Starting our Thread Worker Loop
47:20 - Starting our Socket Connections Loop
48:55 - Primitive Load Balancer to Worker Threads
51:12 - Adding Client Connection to Epoll!
54:14 - Finishing the Network Events in Worker Thread
57:45 - Handling Unsubscribe Events
59:14 - Handling Publish Events
1:00:59 - Adding Clients to Subscriptions Table
1:05:10 - Chunk Based Table Allocations
1:08:14 - Cleaning up Subscriptions on Exit
1:10:14 - Demo Time!