I Wrote Websockets "From Scratch"

  Рет қаралды 19,619

Sean Bix

Sean Bix

17 күн бұрын

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

Пікірлер: 76
@friedpizza262
@friedpizza262 15 күн бұрын
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 14 күн бұрын
@@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!
@MetalManiacBoy
@MetalManiacBoy 15 күн бұрын
Finally someone demystifies TCP/IP and other protocols! My itch has been scratched
@sushidotggg
@sushidotggg 14 күн бұрын
Your YT header made me chuckle. Great vids man
@zaj5924
@zaj5924 15 күн бұрын
awesome vid man, insta-subbed. excited to see more makeup tutorials in the future!
@RahulPatil-vz6hc
@RahulPatil-vz6hc 15 күн бұрын
thanks sir for taking efforts and bringing such good contents.
@ebmpinyuri
@ebmpinyuri 14 күн бұрын
Thank you so much very informative , definitely subscribed to this channel instantly
@LeonardoSantos-lp9hp
@LeonardoSantos-lp9hp 15 күн бұрын
Great content! Liked and subbed. Keep it up!!
@SanjayB-vy4gx
@SanjayB-vy4gx 15 күн бұрын
great content man looking forward for more videos🥳
@marufhasan9365
@marufhasan9365 14 күн бұрын
I would love a video on your overall set up, preferably with better audio quality. Keep up the good work.
@EmmanuelOloyede
@EmmanuelOloyede 13 күн бұрын
Beautiful. Also saw your video on http, I'm subscribing now. Great content!
@Dr.RasheleShoun
@Dr.RasheleShoun 12 күн бұрын
This is awesome! ❤
@N0RT0X
@N0RT0X 15 күн бұрын
underrated channel 🔥
@juliusherbert709
@juliusherbert709 15 күн бұрын
it will evolve! Just a matter of time! Thank u Sir for this invaluable source of deep knowledge!
@eablot8592
@eablot8592 14 күн бұрын
Here cos of Ludwig. Subscribed. All the best.
@etnikg1659
@etnikg1659 13 күн бұрын
Keep Going 🔥🔥
@blvckbytes7329
@blvckbytes7329 8 күн бұрын
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 8 күн бұрын
@@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 8 күн бұрын
@@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 14 күн бұрын
Very cool. C is a great tool for the job.
@reydiansy6774
@reydiansy6774 15 күн бұрын
Great video
@mariusj8542
@mariusj8542 14 күн бұрын
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 15 күн бұрын
excellent video! subscribing
@abrarmasumabir3809
@abrarmasumabir3809 14 күн бұрын
Bro I just subscribed!
@wargnema
@wargnema 14 күн бұрын
thanks for a great video
@Coder.tahsin
@Coder.tahsin 15 күн бұрын
great video
@heydarbadirli
@heydarbadirli 15 күн бұрын
You can use Adobe Podcast to enhance the audio
@yashkumarkasaudhan1354
@yashkumarkasaudhan1354 15 күн бұрын
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 15 күн бұрын
@@yashkumarkasaudhan1354 I noise filter and compress the audio to make the words clearer, but I just have a crummy hardware set up 🤷
@greyshopleskin2315
@greyshopleskin2315 14 күн бұрын
@@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 :)
@emretekin-x8b
@emretekin-x8b 15 күн бұрын
Could you make a video on implementing "RTSP from scratch" ?
@nosh3019
@nosh3019 14 күн бұрын
dude! 🤩
@conandoyle1859
@conandoyle1859 14 күн бұрын
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 14 күн бұрын
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.
@vbhvx7
@vbhvx7 15 күн бұрын
kino. liked and subscribed
@majvax
@majvax 14 күн бұрын
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
@6ugs6unny
@6ugs6unny 15 күн бұрын
Amazing truly great work.
@stasgavrylov
@stasgavrylov 14 күн бұрын
Great video, thank you. If possible, could you make the font size a tad larger next time? 🙏
@seanbix5366
@seanbix5366 14 күн бұрын
@@stasgavrylov of course 🤝
@rajmajumdar5253
@rajmajumdar5253 15 күн бұрын
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 15 күн бұрын
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 🤜
@ckpioo
@ckpioo 15 күн бұрын
amazing, btw what kind of game are you making this for?
@seanbix5366
@seanbix5366 14 күн бұрын
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
@axisaligned9799
@axisaligned9799 14 күн бұрын
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 14 күн бұрын
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!
@mohammedgoder
@mohammedgoder 15 күн бұрын
Hey, great video on WebSocket. Could you make one on WebTransport?
@seanbix5366
@seanbix5366 14 күн бұрын
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 14 күн бұрын
​@@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.
@timemanager3239
@timemanager3239 14 күн бұрын
Thanks
@raunak51299
@raunak51299 14 күн бұрын
Great video! what distro r u using anyways?
@seanbix5366
@seanbix5366 14 күн бұрын
@@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 13 күн бұрын
​@@seanbix5366maybe someday I'll be brave enough to switch to arch.
@siyaram2855
@siyaram2855 14 күн бұрын
Is C the only lang to do such things? Can't JS be used for such things? Just curious
@seanbix5366
@seanbix5366 14 күн бұрын
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 14 күн бұрын
Thanks for responding
@yobeidni
@yobeidni 9 күн бұрын
app used for whiteboarding?
@ratchetdoggo2224
@ratchetdoggo2224 14 күн бұрын
#based
@user-qh5bp2tg4l
@user-qh5bp2tg4l 13 күн бұрын
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 13 күн бұрын
@@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 12 күн бұрын
@@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?
@RespectTheResearch-dy4ed
@RespectTheResearch-dy4ed 15 күн бұрын
Make video about your vim setup
@seanbix5366
@seanbix5366 14 күн бұрын
@@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!
@damianradinoiu4314
@damianradinoiu4314 15 күн бұрын
Could you make a video on implementing "TCP from scratch" ?
@seanbix5366
@seanbix5366 15 күн бұрын
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 14 күн бұрын
Just coded it in computer network lab not that much complex though
@seanbix5366
@seanbix5366 14 күн бұрын
@@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 14 күн бұрын
​​​@@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 14 күн бұрын
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 14 күн бұрын
CRC is definitely more practical to know how to write anyways! Good luck!
@yuvrajkukreja1248
@yuvrajkukreja1248 15 күн бұрын
I am a visual learner however I did not liked the slow pase and boring accent 😞
@seanbix5366
@seanbix5366 15 күн бұрын
@@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 14 күн бұрын
What kind of criticism is that.
@tiranito2834
@tiranito2834 14 күн бұрын
@@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 13 күн бұрын
​@@tiranito2834ikr
@emretekin-x8b
@emretekin-x8b 15 күн бұрын
Could you make a video on implementing "RTSP from scratch" ?
@seanbix5366
@seanbix5366 14 күн бұрын
@@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!
We Need to Rethink Exercise - The Workout Paradox
12:00
Kurzgesagt – In a Nutshell
Рет қаралды 4,4 МЛН
I Wrote HTTP "From Scratch" (It Was Easy)
19:07
Sean Bix
Рет қаралды 49 М.
تجربة أغرب توصيلة شحن ضد القطع تماما
00:56
صدام العزي
Рет қаралды 58 МЛН
God-Tier Developer Roadmap
16:42
Fireship
Рет қаралды 7 МЛН
Making Minimalist Web Server in C on Linux
10:23
Nir Lichtman
Рет қаралды 235 М.
I spent 30 days learning shaders to avoid drawing pixel art
7:49
Turns out REST APIs weren't the answer (and that's OK!)
10:38
Dylan Beattie
Рет қаралды 106 М.
Andrew Kelley   Practical Data Oriented Design (DoD)
46:40
ChimiChanga
Рет қаралды 37 М.
The moment we stopped understanding AI [AlexNet]
17:38
Welch Labs
Рет қаралды 744 М.
I made my own animation library
15:54
Doug Mercer
Рет қаралды 21 М.
HTMX Sucks
25:16
Theo - t3․gg
Рет қаралды 110 М.
So You Think You Know Git - FOSDEM 2024
47:00
GitButler
Рет қаралды 1 МЛН
Git Flow in 100 Seconds
1:40
Byte Pint
Рет қаралды 77
СТРАШНЫЙ ВИРУС НА МАКБУК
0:39
Кринжовый чел
Рет қаралды 1,5 МЛН
Klavye İle Trafik Işığını Yönetmek #shorts
0:18
Osman Kabadayı
Рет қаралды 6 МЛН
Телефон-електрошокер
0:43
RICARDO 2.0
Рет қаралды 1,3 МЛН
😱Хакер взломал зашифрованный ноутбук.
0:54
Последний Оплот Безопасности
Рет қаралды 976 М.