I Wrote Websockets "From Scratch"

Поделиться
HTML-код
  • Опубликовано: 6 июл 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...
  • НаукаНаука

Комментарии • 77

  • @MetalManiacBoy
    @MetalManiacBoy 19 дней назад +26

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

  • @friedpizza262
    @friedpizza262 19 дней назад +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  18 дней назад +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 19 дней назад +2

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

  • @sushidotggg
    @sushidotggg 18 дней назад

    Your YT header made me chuckle. Great vids man

  • @EmmanuelOloyede
    @EmmanuelOloyede 17 дней назад +1

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

  • @RahulPatil-vz6hc
    @RahulPatil-vz6hc 19 дней назад

    thanks sir for taking efforts and bringing such good contents.

  • @LeonardoSantos-lp9hp
    @LeonardoSantos-lp9hp 19 дней назад +1

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

  • @ebmpinyuri
    @ebmpinyuri 18 дней назад

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

  • @SanjayB-vy4gx
    @SanjayB-vy4gx 19 дней назад

    great content man looking forward for more videos🥳

  • @marufhasan9365
    @marufhasan9365 18 дней назад +1

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

  • @eablot8592
    @eablot8592 18 дней назад

    Here cos of Ludwig. Subscribed. All the best.

  • @brookierashele
    @brookierashele 16 дней назад

    This is awesome! ❤

  • @N0RT0X
    @N0RT0X 19 дней назад +4

    underrated channel 🔥

    • @juliusherbert709
      @juliusherbert709 19 дней назад

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

  • @blvckbytes7329
    @blvckbytes7329 12 дней назад

    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  12 дней назад +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 12 дней назад

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

  • @nigelhungerford-symes5059
    @nigelhungerford-symes5059 18 дней назад

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

  • @etnikg1659
    @etnikg1659 17 дней назад +1

    Keep Going 🔥🔥

  • @mariusj8542
    @mariusj8542 18 дней назад

    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!

  • @briandepazdiaz
    @briandepazdiaz 19 дней назад

    excellent video! subscribing

  • @reydiansy6774
    @reydiansy6774 19 дней назад +2

    Great video

  • @abrarmasumabir3809
    @abrarmasumabir3809 18 дней назад

    Bro I just subscribed!

  • @Coder.tahsin
    @Coder.tahsin 19 дней назад +1

    great video

  • @wargnema
    @wargnema 18 дней назад

    thanks for a great video

  • @vbhvx7
    @vbhvx7 19 дней назад

    kino.
    liked and subscribed

  • @nosh3019
    @nosh3019 18 дней назад

    dude! 🤩

  • @heydarbadirli
    @heydarbadirli 19 дней назад +1

    You can use Adobe Podcast to enhance the audio

  • @majvax
    @majvax 18 дней назад

    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

  • @yashkumarkasaudhan1354
    @yashkumarkasaudhan1354 19 дней назад +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  19 дней назад

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

    • @greyshopleskin2315
      @greyshopleskin2315 18 дней назад

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

  • @6ugs6unny
    @6ugs6unny 19 дней назад

    Amazing truly great work.

  • @conandoyle1859
    @conandoyle1859 18 дней назад

    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  18 дней назад

      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.

  • @timemanager3239
    @timemanager3239 18 дней назад

    Thanks

  • @stasgavrylov
    @stasgavrylov 18 дней назад

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

    • @seanbix5366
      @seanbix5366  18 дней назад

      @@stasgavrylov of course 🤝

  • @ckpioo
    @ckpioo 19 дней назад

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

    • @seanbix5366
      @seanbix5366  18 дней назад

      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

  • @rajmajumdar5253
    @rajmajumdar5253 19 дней назад

    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  19 дней назад

      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 🤜

  • @emretekin-x8b
    @emretekin-x8b 19 дней назад

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

  • @raunak51299
    @raunak51299 18 дней назад

    Great video! what distro r u using anyways?

    • @seanbix5366
      @seanbix5366  18 дней назад

      @@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 17 дней назад

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

  • @axisaligned9799
    @axisaligned9799 18 дней назад +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  18 дней назад +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 2 дня назад

      In IT examples are always easy.

  • @mohammedgoder
    @mohammedgoder 19 дней назад

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

    • @seanbix5366
      @seanbix5366  18 дней назад

      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 18 дней назад

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

  • @user-qh5bp2tg4l
    @user-qh5bp2tg4l 17 дней назад

    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  17 дней назад +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 16 дней назад

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

  • @ratchetdoggo2224
    @ratchetdoggo2224 18 дней назад

    #based

  • @siyaram2855
    @siyaram2855 18 дней назад

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

    • @seanbix5366
      @seanbix5366  18 дней назад

      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 18 дней назад

      Thanks for responding

  • @RespectTheResearch-dy4ed
    @RespectTheResearch-dy4ed 19 дней назад

    Make video about your vim setup

    • @seanbix5366
      @seanbix5366  18 дней назад

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

  • @yobeidni
    @yobeidni 13 дней назад

    app used for whiteboarding?

  • @sankhadip_roy
    @sankhadip_roy 18 дней назад

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

    • @seanbix5366
      @seanbix5366  18 дней назад +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 18 дней назад

      ​​​@@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 18 дней назад

      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  18 дней назад

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

  • @damianradinoiu4314
    @damianradinoiu4314 19 дней назад

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

    • @seanbix5366
      @seanbix5366  19 дней назад

      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.

  • @yuvrajkukreja1248
    @yuvrajkukreja1248 19 дней назад +1

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

    • @seanbix5366
      @seanbix5366  19 дней назад

      @@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 18 дней назад +1

      What kind of criticism is that.

    • @tiranito2834
      @tiranito2834 18 дней назад

      @@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 17 дней назад

      ​@@tiranito2834ikr

  • @emretekin-x8b
    @emretekin-x8b 19 дней назад

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

    • @seanbix5366
      @seanbix5366  18 дней назад +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!