@@energy-tunes original spec is linked. I implemented a working subset I needed in like 2-3 coding sessions. The hardest part was probably MIME types and understanding + writing CORS. What took longer was just making a useful interface to the Linux socket API...
As a C# engineer I genuinely laughed at "Aha, aha, aha... It would appear that Mr. Gates has blessed my terminal with OOP, but hey at least .NET is cross platform." 🤣🤣🤣 MS documentation is surely dry as a bone.
Thank you very much for encouraging me to roll my own websocket code! My situation is that I am working on embedded devices, where I connect to the internet over either WiFi or Ethernet, and use chips like the ESP8266 or the ATmega328P, and need realtime communication to accept commands and synchronize state between multiple clients via events. Various existing libraries are an overly complicated mess of multiple layers of abstraction, next to hundreds of preprocessor macros, due to all kinds of hardware permutations - needless clutter, and heavy use of the std-lib. My little project will be up in no time, now that I can write application-specific code! :))
@@blvckbytes7329 Right on! That _is_ how it do be. Do it, and thanks for watching! I was considering making a video about setting up the AVR compiler toolchain, and/or the arduino CLI, as I see professionals still using the Arduino IDE for chips like the ATmega328P (which I've specifically worked with recently!).
@@seanbix5366 Right? I've read another comment of yours, where you said how people just use things without any understanding of their underlying working principles whatsoever; if society ever collapsed, only very few would know how to rebuild technology from scratch... Same goes for mathematics, but that's a whole other can of worms, ;). I'm just so disappointed at how needlessly complicated simple things became by now. All I want to do is to control a few I/O-lines using a browser via Ethernet, and I'm literally wrangling with dozens of libraries and build-errors since multiple hours. By now, I could've written the library myself, haha - which is what I am now doing! :) Would love to see that video about AVR programming. I am currently using PlatformIO, because it "just works" (most of the time, if VSCode isn't bug-riddled again). The Arduino "IDE" lacks too many critical features to get anything beyond a blinking LED done, at least IMHO.
Hah! Nice try, Sense Of Child-like Wonder! Unfortunately, I want to finish the project and get it working. SSL/TLS is a whole new can if worms for another time...
@@xorxpert Nice! I have a websocket deepdive on this channel too- the variable length length encoding and payload masking were wicked, but worth it in the end!
@@seanbix5366 It was mostly challenging for me at the time. I usually like to learn how things work for experience but mostly avoiding third party or standard libraries. Whilst working on a multiplayer game, I built my own websocket server & client in the process along with a protocol library, for handling sending packets efficiently properly writing/reading and parsing data (binary), while converting between respectable objects. latency was very important, all unmanaged code. Performance, speed, and efficiency was the focus. Per protocol standard for large payloads, you have to deal with splitting the data into frames, and you know TCP, you got to handle waiting and acknowledging packets - multi (safe) threaded 😅 Took me about a mouth until i was entirely finished it, though was fun and worth learning!
@@xorxpert So far none of my websocket payloads are larger than a few dozen bytes... But I was under the impression that I could simply cram an arbitrary amount of data after a websocket header and TCP would eat it? I don't remember, need to look at the code! I fetch all the BIG data with http from JS anyways.... Good work! I couldn't even find a simple websocket library anyways.
Dude! Ever heard of scope? As for someone who claims he wrote this code himself, you talk surprisingly few about the code, and surprisingly lot about unrelated deeper layers of protocols that you don't even attempt to implement yourself, and which are therefore totally outside of the scope.
Fair. I suspected the overlap between between people who don't know HTTP and how the TCP/IP stack works was near 1:1, and targeted that audience. The implementation itself is not impressive (it's in the title) but it seems to have served it's purpose in giving lots of people a deeper intuition for the entire system (and powering my webserver)! I'm sure we can agree that conventional explanations (like wrapping a parcel) fall short.
weird seeing actual devs that sees this as witchcraft, you got to understande how to build everything from scratch. imagine if humanity rebooted and we can't even build internet again.
@@user-qh5bp2tg4l I'm just a lowly IT dude with some curiosity. However, one of the first things that was imparted to me when I entered the field was "The bits and bytes don't matter, just remember this button sequence". People are happy to push a few buttons and collect a salary, even if an empty ROM is a few thousand bytes away from being a profitable system. And that's okay! But I don't envy the confusion they must feel, nor the reliance on a massive proprietary system to "just work"...
@@seanbix5366 "even if an empty ROM is a few thousand bytes away from being a profitable system." this quote express how the IT industry enslaves the worker on developing based on someone's low level work. "even if an empty ROM is a few thousand bytes away from being a profitable system." can you elaborate on this?
Cudos on this project and the way you went through the code. I work a lot with both axios websockets in js and asyncio in python. But i needed to write a “websocket” for an stm32 processor just a few weeks back which i wrote in C++ as you do, too bad i did not know about your work. Since i just needed to solve much of the same problem you solved, full duplex and an efficient way of doing handshakes, with minimal headersize. I just “Jerry rigged” a poor mans version, but not as your good as your work. Nicely done!
You know, all these modern development frameworks hide a lot of relatively low-level code that is necessary to understand how your application works. I am a Java programmer and we have this Spring framework, with the help of which you can develop WEB apps and much more. When I wanted to use websocket it was quite simple, you only had to write a couple of lines of code and Spring would do the rest for you, but if you want to do something more complicated than the basic example and from the first article of the official documentation, then you have difficulties. And the point is not that you don’t know the framework well, the point is that you don’t know the basics of the WebSocket technology used. Then I started with the basics - I wrote a simple http server with the functionality I needed, I used only the standard java library. Then I implemented the webSocket protocol and then everything fell into place! All the questions I had are gone! Everything turned out to be so simple! The problem with modern programmers is that we write very high-level code and do not understand it, since we do not know the basics, which are not taught in universities
Try and start from the bottom up I say! How can you drive a car when you don't know how the wheels turn? Doable, but definitely worse. Thank you for the insight.
JS on the server side is one of the top 10 evils to befall mankind. That being said, yes sure! JS had high level interfaces for all of this functionality. The browser client featured in the video is written in JS!
http & (ws) websockets are approachable & implementable by most. but man, https and wss (TLS/SSL) is where it becomes a pain in the ass lol. hand-implementing TLS is a nightmare. still doable but the random math cipher-suites to implement is tedious
I was tempted to try, but just learning a library for this seemed like a useful enough skill on its own. I don't trust myself to make something secure enough for this particular project, but I'd love to try in future!
@@raunak51299 Plain old Arch. Has served me solidly as a desktop OS for years now. Always get the latest updates and literally everything ever is in the aur
@@sankhadip_roy True. Seems obvious to those that know of course, but as an outsider looking in trying to grasp networking i can imagine it's a bit cryptic!
@@seanbix5366Yea, that's right. As an cs student it seems familiar but for an outsider from a non tech field its horrible. I was also little panicking if this comes in my network lab semester exam. Got the cyclic redundancy checking code instead.