I Wrote Websockets "From Scratch"

Sdílet
Vložit
  • čas přidán 6. 07. 2024
  • Real-time, bi-directional TCP in the browser.
    I explain how Websocket protocol works down to every byte,
    and show it in action.
    Note this is HTTP 1.1, but should be similar enough for
    HTTP 2 and 3.
    I also mention TLS/SSL!
    Project Link: github.com/Bixkitts/relic-mer...
    Docs: developer.mozilla.org/en-US/d...
    HTTP & OSI Video I Made Prior: • I Wrote HTTP "From Scr...
  • Věda a technologie

Komentáře • 77

  • @MetalManiacBoy
    @MetalManiacBoy Před 18 dny +26

    Finally someone demystifies TCP/IP and other protocols! My itch has been scratched

  • @friedpizza262
    @friedpizza262 Před 18 dny +26

    I though the video was just a highlight, cause instinctively you'd think implementing web-sockets protocol yourself is a crazy thought. I wouldn't have been brave enough to think it can be anything but painful!

    • @seanbix5366
      @seanbix5366  Před 18 dny +5

      @@friedpizza262 yeah I initially gave up when trying to find a usable C/C++ library for this years ago, only thought to look into it again recently.
      Didn't even cross my mind to implement it but I found myself looking up the standard anyways and well, profit.
      There's typically a life saving difference between a working implementation and a complete implementation of anything, so never dismiss just writing the 10% you need personally!

  • @zaj5924
    @zaj5924 Před 18 dny +2

    awesome vid man, insta-subbed. excited to see more makeup tutorials in the future!

  • @sushidotggg
    @sushidotggg Před 17 dny

    Your YT header made me chuckle. Great vids man

  • @EmmanuelOloyede
    @EmmanuelOloyede Před 17 dny +1

    Beautiful. Also saw your video on http, I'm subscribing now.
    Great content!

  • @LeonardoSantos-lp9hp
    @LeonardoSantos-lp9hp Před 19 dny +1

    Great content! Liked and subbed. Keep it up!!

  • @RahulPatil-vz6hc
    @RahulPatil-vz6hc Před 18 dny

    thanks sir for taking efforts and bringing such good contents.

  • @N0RT0X
    @N0RT0X Před 19 dny +4

    underrated channel 🔥

    • @juliusherbert709
      @juliusherbert709 Před 19 dny

      it will evolve! Just a matter of time! Thank u Sir for this invaluable source of deep knowledge!

  • @etnikg1659
    @etnikg1659 Před 16 dny +1

    Keep Going 🔥🔥

  • @SanjayB-vy4gx
    @SanjayB-vy4gx Před 19 dny

    great content man looking forward for more videos🥳

  • @marufhasan9365
    @marufhasan9365 Před 18 dny +1

    I would love a video on your overall set up, preferably with better audio quality. Keep up the good work.

  • @eablot8592
    @eablot8592 Před 17 dny

    Here cos of Ludwig. Subscribed. All the best.

  • @brookierashele
    @brookierashele Před 16 dny

    This is awesome! ❤

  • @ebmpinyuri
    @ebmpinyuri Před 18 dny

    Thank you so much very informative , definitely subscribed to this channel instantly

  • @reydiansy6774
    @reydiansy6774 Před 18 dny +2

    Great video

  • @abrarmasumabir3809
    @abrarmasumabir3809 Před 17 dny

    Bro I just subscribed!

  • @briandepazdiaz
    @briandepazdiaz Před 18 dny

    excellent video! subscribing

  • @Coder.tahsin
    @Coder.tahsin Před 19 dny +1

    great video

  • @nigelhungerford-symes5059

    Very cool. C is a great tool for the job.

  • @wargnema
    @wargnema Před 18 dny

    thanks for a great video

  • @blvckbytes7329
    @blvckbytes7329 Před 12 dny

    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! :))

    • @seanbix5366
      @seanbix5366  Před 12 dny +1

      @@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!).

    • @blvckbytes7329
      @blvckbytes7329 Před 12 dny

      @@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.

  • @mariusj8542
    @mariusj8542 Před 17 dny

    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!

  • @vbhvx7
    @vbhvx7 Před 18 dny

    kino.
    liked and subscribed

  • @nosh3019
    @nosh3019 Před 17 dny

    dude! 🤩

  • @heydarbadirli
    @heydarbadirli Před 18 dny +1

    You can use Adobe Podcast to enhance the audio

  • @majvax
    @majvax Před 17 dny

    I did somewhat the same but using windows api was harsh to do honestly since I didn't have any experiences in this field but It's verh informative

  • @stasgavrylov
    @stasgavrylov Před 18 dny

    Great video, thank you. If possible, could you make the font size a tad larger next time? 🙏

  • @timemanager3239
    @timemanager3239 Před 18 dny

    Thanks

  • @emretekin-x8b
    @emretekin-x8b Před 18 dny

    Could you make a video on implementing "RTSP from scratch" ?

  • @yashkumarkasaudhan1354
    @yashkumarkasaudhan1354 Před 19 dny +5

    great video but could you please work on the audio. i have to use earphone to clearly understand that. because managing subtitle, audio, and content of video all of this becomes complex.

    • @seanbix5366
      @seanbix5366  Před 19 dny

      @@yashkumarkasaudhan1354 I noise filter and compress the audio to make the words clearer, but I just have a crummy hardware set up 🤷

    • @greyshopleskin2315
      @greyshopleskin2315 Před 17 dny

      @@seanbix5366i don’t know your hw setup, so can’t give specific advice. I guess the problem is not your mic?
      If fixing your setup is hard or expensive and want to fix your audio, maybe you could just use your phone to record audio and then add it to the video.
      Microphones of phones aren’t the best, but it will probably be good enough :)

  • @rajmajumdar5253
    @rajmajumdar5253 Před 19 dny

    Damn thats 🤩🤩🤩🤩🤩 , can you also do auth in C? Or maybe something like STUN and TURN servers and why do we need them in WebRTC.

    • @seanbix5366
      @seanbix5366  Před 19 dny

      Server already features basic token authentication, but it is not very secure.
      I'll consider making a video about that when, and if, I harden it 🤜

  • @mohammedgoder
    @mohammedgoder Před 18 dny

    Hey, great video on WebSocket.
    Could you make one on WebTransport?

    • @seanbix5366
      @seanbix5366  Před 18 dny

      Oh that exists?
      Dope and thank you.
      When (and if...) my project is finished I'll definitely consider migrating to http3 and WebTransport (and documenting it here of course).
      Sounds like agony/fun

    • @mohammedgoder
      @mohammedgoder Před 18 dny

      ​@@seanbix5366 To be honest; I don't like webdev stuff.
      So I wanted to pawn off the work of parsing through the garbage in the published material to conjure up a working prototype.
      It's probably gonna be a painful endeavor.
      They really should allow devs to access raw UDP sockets.

  • @ckpioo
    @ckpioo Před 18 dny

    amazing, btw what kind of game are you making this for?

    • @seanbix5366
      @seanbix5366  Před 18 dny

      Thank you!
      Multiplayer digital board game, made to be a faster/better/custom clone of a game my friends and I play!
      I really need a frontend guy, JS is brain rot :c

  • @6ugs6unny
    @6ugs6unny Před 18 dny

    Amazing truly great work.

  • @raunak51299
    @raunak51299 Před 18 dny

    Great video! what distro r u using anyways?

    • @seanbix5366
      @seanbix5366  Před 18 dny

      @@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

    • @raunak51299
      @raunak51299 Před 17 dny

      ​@@seanbix5366maybe someday I'll be brave enough to switch to arch.

  • @conandoyle1859
    @conandoyle1859 Před 18 dny

    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

    • @seanbix5366
      @seanbix5366  Před 18 dny

      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.

  • @axisaligned9799
    @axisaligned9799 Před 18 dny +2

    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

    • @seanbix5366
      @seanbix5366  Před 18 dny +1

      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!

    • @SangramMukherjee
      @SangramMukherjee Před dnem

      In IT examples are always easy.

  • @ratchetdoggo2224
    @ratchetdoggo2224 Před 18 dny

    #based

  • @siyaram2855
    @siyaram2855 Před 18 dny

    Is C the only lang to do such things?
    Can't JS be used for such things? Just curious

    • @seanbix5366
      @seanbix5366  Před 18 dny

      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!

    • @siyaram2855
      @siyaram2855 Před 17 dny

      Thanks for responding

  • @RespectTheResearch-dy4ed

    Make video about your vim setup

    • @seanbix5366
      @seanbix5366  Před 18 dny

      @@RespectTheResearch-dy4ed Might be worth it. I dislike just downloading someone else's configuration for fear of it breaking when I simply want to write something.
      I meticulously picked and configured everything myself!

  • @user-qh5bp2tg4l
    @user-qh5bp2tg4l Před 16 dny

    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.

    • @seanbix5366
      @seanbix5366  Před 16 dny +2

      @@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"...

    • @user-qh5bp2tg4l
      @user-qh5bp2tg4l Před 16 dny

      @@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?

  • @yobeidni
    @yobeidni Před 13 dny

    app used for whiteboarding?

  • @damianradinoiu4314
    @damianradinoiu4314 Před 19 dny

    Could you make a video on implementing "TCP from scratch" ?

    • @seanbix5366
      @seanbix5366  Před 19 dny

      If I were to go to the trouble to implement a transport layer protocol for x86_64, it would be QUIC over UDP!
      I'll need to if I switch to http 3.
      I may need to do TCP for a microcontroller however, so if that happens, I'll make a video about it.

  • @sankhadip_roy
    @sankhadip_roy Před 18 dny

    Just coded it in computer network lab not that much complex though

    • @seanbix5366
      @seanbix5366  Před 18 dny +1

      @@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!

    • @sankhadip_roy
      @sankhadip_roy Před 18 dny

      ​​​@@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.

    • @sankhadip_roy
      @sankhadip_roy Před 18 dny

      After seeing this type of video getting good amount of view. I am in guilt why I didn't make a video on this when I was in the previous semester.

    • @seanbix5366
      @seanbix5366  Před 18 dny

      CRC is definitely more practical to know how to write anyways!
      Good luck!

  • @yuvrajkukreja1248
    @yuvrajkukreja1248 Před 18 dny +1

    I am a visual learner however I did not liked the slow pase and boring accent 😞

    • @seanbix5366
      @seanbix5366  Před 18 dny

      @@yuvrajkukreja1248 I prefer the term "methodical" :( ... The linked document and websocket RFC itself are very approachable compared to other ones I've read, so you'll also get a good explanation straight from the source!

    • @raunak51299
      @raunak51299 Před 18 dny +1

      What kind of criticism is that.

    • @tiranito2834
      @tiranito2834 Před 18 dny

      @@raunak51299 The kind of criticism that should be ignored. "I don't like your video because you actually teach, waaa waaaa, my short attention span cannot handle this!!!" is all I heard when I read the comment lol.

    • @raunak51299
      @raunak51299 Před 17 dny

      ​@@tiranito2834ikr

  • @emretekin-x8b
    @emretekin-x8b Před 18 dny

    Could you make a video on implementing "RTSP from scratch" ?

    • @seanbix5366
      @seanbix5366  Před 18 dny +1

      @@emretekin-x8b I didn't know what that was, but now I see.
      If I encounter it in my career, I'll consider it thank you!