How to Write a Socket Server from Start to Finish!

  Рет қаралды 2,819

hoff._world

hoff._world

Күн бұрын

Пікірлер: 34
@GregTash
@GregTash 8 ай бұрын
this channel is a hidden gem
@hoff._world
@hoff._world 8 ай бұрын
yeah you have to mine below layer 16 around y -53 it seems
@CYBERNETIC-ANGEL
@CYBERNETIC-ANGEL 8 ай бұрын
so glad i discovered this channel
@thehady1
@thehady1 8 ай бұрын
I'll always wonder how and where you learn to be this great.i really admire you and look up to you !great video btw
@MateoEstudiante
@MateoEstudiante 8 ай бұрын
Hey. Your content is gold! Thanks for sharing. Hoping you the best.
@Blue-bb9ro
@Blue-bb9ro 8 ай бұрын
Love your channel, learning so much. Thank you.
@gmeister3022
@gmeister3022 8 ай бұрын
The GOAT is back
@hoff._world
@hoff._world 8 ай бұрын
what can I say ur boy loves to cook
@juststudying1019
@juststudying1019 8 ай бұрын
Thanks your channel is amazin, please keep uploading videos like this. They are very usefull.
@hoff._world
@hoff._world 8 ай бұрын
dont sweat it chief will keep em coming :)
@mangeshshikrodkar6192
@mangeshshikrodkar6192 8 ай бұрын
just amazing
@mblenczewski
@mblenczewski 8 ай бұрын
Nice video! With your locking, it seems that reads are more likely than writes (when walking the watch entry table, for example). Why not use `pthread_rwlock_t` instead of `pthread_mutex_t`, to avoid some unnecessary lock contention in the common case of reading? Also, in your makefile, why not use `cc` instead of `gcc`, to have builds "Just Work" on systems where gcc isn't installed by default. Finally, I appreciate that these videos are already very long, and must take at absolute minimum twice that to edit together and publish. They are well put together. Would it at all be possible in future to spend some more time working through the architecture and dataflow? Perhaps on a virtual whiteboard or in a paint program? I ask as I found myself rather lost with how you manage connection state (pointers into the watch table for publishers/rolexhound, and no state for subscribers?), even after rewatching the architecture segment and attempting to look over the code. It should be very simple, and I can convince myself of this when coming up with my own solution to the problem, but there is just something I am missing with your solution.
@hoff._world
@hoff._world 8 ай бұрын
hey thanks 1. yep you totally could, and I did consider it but ultimately couldn't be bothered to think about all the situations where I'd only be reading or writing and applying the appropriate lock. Definitely a valid substitute for a full mutex tho. 2. ye fair but tbh I kind of expect people to do up their own makefiles I just include mine as an example, if someone cant figure out how to change the C compiler in it then they should take a step back before doing this project for example :D 3. I'd really like to and in fact I had done theory videos before but they generally get the comments filled with people asking for the implementation :D I'm gonna be trying a bunch of stuff out over the coming weeks and will get a better idea of what people wanna see, cheers for the thoughts 4. Yep I agree I didn't really explain that bit so well. It's easy if you have the context loaded in your head to sometimes skip explaining things that may not be obvious to someone fresh: Basically I didn't want 2 tables (for complexity/video length reasons) so instead of keeping track of rolexhound instances separately to smartwatch subscriptions he will initialise himself onto the sub table with a NULL watchPath and non-NULL activeFiles. Our table scan function can see who is a rolexhound by matching those parameters. It can also find a 'free' spot on the table for a new subscription by finding an entry where watchPath is NULL and so is activeFiles. A smartwatch subscription entry will have a non-NULL watchPath, a non-NULL activeFiles and a non-0 sub and pubFd. Hope that clears it up :)
@mblenczewski
@mblenczewski 8 ай бұрын
​@@hoff._worldYes, thank you very much for the clarification, and again, good video. Looking forward to the next ones :)
@benhetland576
@benhetland576 8 ай бұрын
The mutex juggling was what I felt most uncomfortable with, especially within the loops where there are break/continue/return to jump past a matching pair of lock--unlock. There is no longer only the two calls with a guaranteed execution path crossing both of them every time, or at least it is very difficult to assertain so when reading the code. After leaving such a loop there is a situation that sometimes a lock is held, and sometimes not. That is a recipe for writing a bug, especially within all that logic with if-statements, which is known to be maybe the most common cause of programming errors! Deadlocks be waiting to strike one dark night...
@mblenczewski
@mblenczewski 8 ай бұрын
​​@@benhetland576 Completely agree, that code is quite hairy. I would have personally tried to factor the shared table access into separate, smaller helper functions to help guarantee correctness. With this approach of splitting both publishers and subscribers across multiple threads, I don't naively see a way to avoid the locking, without either moving to more complex lock-free datastructures (which i am not knowledgeable enough in), or by moving from shared data to a sharded approach (at the cost of reduced functionality; watches no longer cross the thread/shard boundary). Currently trying to implement my own version of this server as well, to see what problems there are to solve. After all, I can't just sit here critiquing code without putting some action behind my words :)
@hoff._world
@hoff._world 8 ай бұрын
@benhetland576 I have tried to be careful with my un/locking positioning despite that, but as you say time will tell :D
@Palatonista
@Palatonista 8 ай бұрын
The man is cookin
@hoff._world
@hoff._world 8 ай бұрын
KDE Plasma 6 just dropped, so I may do a setup video once I get it all installed :)
@Palatonista
@Palatonista 8 ай бұрын
@@hoff._world POG
@illegalsmirf
@illegalsmirf 8 ай бұрын
BASED gigachad 💪🤓
@bakhtyarsayed
@bakhtyarsayed 8 ай бұрын
How does he keep making bangers???
@hoff._world
@hoff._world 8 ай бұрын
just 👏 🔥 built different 💯 💯 👌
@Shxvang
@Shxvang 8 ай бұрын
very kool
@benhetland576
@benhetland576 8 ай бұрын
28:40 It is pretty useless to call that _watch_entry_factory_ before returning. You will only affect the local copy of the struct, which you will not use afterwards anyway. Actually the whole way you pass that _matchEntry_ parameter is pretty dangerous! The struct will be copied, which includes the pointers it contains. There's no fancy copy constructor in C to manage the pointer members, like you could have in C++, so you have duplicate ptrs to the same string memories. Should you have called the _reset_ function instead you would have a double-free later on. Now, you called the _factory,_ which luckily avoids calling _free_ (no need to test for NULL btw), so you avoid the double-free at the risk of leaking memory instead, but it is totally pointless since the variable goes out of scope immediately afterwards. ;-)
@hoff._world
@hoff._world 8 ай бұрын
Hmm I should have passed the pointer of the match entry struct since my intention was to pass by reference, missed that thanks. Given that context the rest of the logic for resetting it is correct.
@benhetland576
@benhetland576 8 ай бұрын
@@hoff._world Bingo! Yes, even a const ptr maybe. That's both the good and the awkward thing about C -- we have to be explicit about everything and every nitty gritty detail. Let the caller have all the responsibility for that struct, including resets if needed.
@benhetland576
@benhetland576 8 ай бұрын
@@hoff._world Otherwise you have made quite an elaborate video there, man! Even after the shortcuts with memory handling. Nice work!
@BoBo-nv9qu
@BoBo-nv9qu 6 ай бұрын
Useful video.
@hoff._world
@hoff._world 6 ай бұрын
thanks xx
@ACium.
@ACium. 8 ай бұрын
which editor is this?
@hoff._world
@hoff._world 8 ай бұрын
it do be Kate
All About Epoll - Scalable I/O Syscalls in Linux!
19:22
hoff._world
Рет қаралды 5 М.
How to Actually Start a Software Project!
27:45
hoff._world
Рет қаралды 7 М.
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 9 МЛН
Implementing a Network Protocol in C from Start to Finish!
1:22:52
C Programming Tutorial for Beginners
3:46:13
freeCodeCamp.org
Рет қаралды 14 МЛН
TCP/IP for Programmers
3:03:31
Eli the Computer Guy
Рет қаралды 224 М.
Snowflake
1:17:52
Jignesh Patel
Рет қаралды 817
The Quest To Make Unbreakable Glass
22:23
Veritasium
Рет қаралды 2,7 МЛН
The Tragedy of systemd
47:18
linux.conf.au
Рет қаралды 1,1 МЛН
NSA Releases Internal 1982 Lecture by Computing Pioneer Rear Admiral Grace Hopper
1:29:36
The Black Vault Originals
Рет қаралды 286 М.
node.js-like C++ Async Streams Pipeline - Sane C++ Libraries [ep.30]
1:31:30
Getting Good at Programming
13:23
hoff._world
Рет қаралды 4,5 М.