coding in C but I start over for every compiler error

Sdílet
Vložit
  • čas přidán 21. 09. 2022
  • TODAY I TAKE ON A MIGHTY CHALLENGE. A QUEST THAT NO OTHER PROGRAMMER OR CONTENT CREATOR WILL TAKE ON FOR THEIR VIEWERS.
    Today I will program a TCP Server and Client in C, but there is a catch. First, I will create this socket server and client, but if I get ANY compilation errors, I will delete ALL OF MY CODE AND START OVER. Two, I will not be using an outside resources. I will instead only be using the man pages that come with Linux.
    Wish me luck.
    🏫 COURSES 🏫
    www.udemy.com/course/c-progra...
    🔥🔥🔥 SOCIALS 🔥🔥🔥
    Low Level Merch!: www.linktr.ee/lowlevellearning
    Follow me on Twitter: / lowleveltweets
    Follow me on Twitch: / lowlevellearning
    Join me on Discord!: / discord
  • Věda a technologie

Komentáře • 342

  • @LowLevelLearning
    @LowLevelLearning  Před rokem +33

    follow me on twitter please 👉 👈 twitter.com/lowlevellearni1

    • @gameplayyt504
      @gameplayyt504 Před rokem +1

      Hey man, Do you run your code through WSL?

    • @eug3n33
      @eug3n33 Před rokem +1

      Hello, i have one question, i hope you may take an answer on it. What font do you use in this video?

    • @vincent4070
      @vincent4070 Před rokem

      Next challenge: repeat this with
      echo | gcc -x

    • @circuit10
      @circuit10 Před rokem

      @@gameplayyt504 It's native Linux

  • @minirop
    @minirop Před rokem +1397

    Now onto the hard mode, compile with: -Wall -Wextra -pedantic -Werrors -Wconversion

    • @LowLevelLearning
      @LowLevelLearning  Před rokem +681

      I had to make sure the video adhered to the CZcams under 24 hour guideline LOLOL

    • @TheMLover
      @TheMLover Před rokem +147

      I preffer -pedantic-errors -fstack-protect-all -std=c89

    • @KaranveerSingh97
      @KaranveerSingh97 Před rokem +72

      @@TheMLover hahahaha... c89 lol

    • @TheMLover
      @TheMLover Před rokem +37

      @@KaranveerSingh97 the OG mode

    • @doublepmcl6391
      @doublepmcl6391 Před rokem +30

      @@KaranveerSingh97 LooL not with c89 😂 this would be getting ridiculous

  • @pokemettilp8872
    @pokemettilp8872 Před rokem +550

    I learned a great practice: "TODO: Make code good"
    Imma put this after every line of code now!

    • @LowLevelLearning
      @LowLevelLearning  Před rokem +92

      YOURE LEARNING FROM THE BEST

    • @not_ever
      @not_ever Před rokem +19

      I prefer the convention of putting the TODO before each line of code. This way people know what to expect on the next line and the bar has been set as low as possible, so no one can be disappointed.

    • @arthur979
      @arthur979 Před rokem +11

      // do client stuff

    • @sobanya_228
      @sobanya_228 Před rokem +18

      Don’t repeat yourself. Put all the code inside a single todo block

  • @CyrillKR
    @CyrillKR Před rokem +387

    This is honestly better than watching an hour long tutorial of an introduction for writing sockets in C.

    • @lmaox265
      @lmaox265 Před rokem +2

      Could you explain to me what the application of a program like this is ?

    • @amritlohia8240
      @amritlohia8240 Před rokem +5

      @@lmaox265 To run a server, basically.

  • @Kenyerman
    @Kenyerman Před rokem +114

    -Wall -Werror

  • @sprytnychomik
    @sprytnychomik Před rokem +48

    "Warnings are not errors"
    Only runtime can tell... ; )

  • @petermuller608
    @petermuller608 Před rokem +57

    Great video idea. I especially like the "no outside resources" part. This was the default up to like 2005 for most of us :D

  • @dooza
    @dooza Před rokem +26

    I didn't have prior knowledge to C before my networking class and we literally just had this assignment. It was still hard with Stack Overflow help, because most C socket programming guides were written in plain HTML and were uploaded to some random subdirectory in a webserver at some university in 2002.
    But, MAN did I learn how man pages work!

  • @silentparrot8510
    @silentparrot8510 Před rokem +164

    You inspired me to make a calculator interface in c++ with qt designer, but everytime its ugly i retype everything, wish me luck

  • @ahmedsaadsabit1749
    @ahmedsaadsabit1749 Před rokem +1

    I have begun to love this channel so much, some more low level content would be fucking amazing!

  • @LoomMexatron
    @LoomMexatron Před rokem +158

    I am rather impressed. Not many people have the courage to do such challenge with such rules!

    • @CallousCoder
      @CallousCoder Před rokem +9

      I called it the sadomasochistic challenge! 😃

    • @Dyanosis
      @Dyanosis Před rokem

      What challenge? He basically copied from the man docs.

    • @ronen124
      @ronen124 Před rokem

      @@Dyanosis he knew much more than that
      [edit: I fixed a poor typo error I made]

    • @deang5622
      @deang5622 Před rokem

      It's a pointless challenge: it achieves absolutely nothing.

    • @deang5622
      @deang5622 Před rokem +1

      @@Dyanosis Nobody knows the specifics of every function within all the installed packages, looking up documentation is an essential part of any programmer's job.
      However, it is completely pointless challenge. It has no value whatsoever.
      I have been programming for 40 years, and yes you occasionally get the number of arguments wrong for a function, no one in their right mind deletes all their code and starts again. No one.

  • @RyanLynch1
    @RyanLynch1 Před rokem +5

    very cool idea and a clever gimmick! hope you do more of these

  • @isabelpino1987
    @isabelpino1987 Před rokem +3

    With your videos my learning curve will shrink drastically. Thank you.

  • @sohn7767
    @sohn7767 Před rokem +138

    This feels like a Speedrun but every error is a huge timeloss so you reset

    • @Ululukiful
      @Ululukiful Před rokem +4

      Yeah I also thought of steel soul/iron man programming

  • @Ecks1118
    @Ecks1118 Před rokem +42

    Genuinely one of the most entertaining, professional, and helpful programming youtubers I know, you're very cool. This is also a very "fun" challenge idea.

  • @notyaniecetv
    @notyaniecetv Před rokem +1

    I just know this is a GREAT way to learn ! 😂 Leaving a comment so I can come back to this when I get off

  • @pwnwriter
    @pwnwriter Před rokem +4

    Learnt a lottt
    Pls do these type of challenges moreeeee.

  • @davga2300
    @davga2300 Před rokem

    This was an excellent video! Thanks. I need to try this sometime as it will probably improve my programming skills.

  • @heitormbonfim
    @heitormbonfim Před rokem +8

    Great one, bruh. Just make sure to give a ctrl + (plus) to zoom in a bit and a ctrl + B to get rid of the side bar showing the files.

  • @pallzoltan
    @pallzoltan Před rokem

    Man youre crazy .)) Love your videos

  • @kalelalves
    @kalelalves Před rokem +7

    I don't think I ever felt so stressed out from watching someone code. hahaha

  • @rallokkcaz
    @rallokkcaz Před rokem +4

    LOW LEVEL GANG! This is what's up! Great video as always my dude. htons time.

  • @spinspin1597
    @spinspin1597 Před rokem +1

    It is genuinely so nice to see someone else using wmi3, like seriously it really made my day lol

  • @mhsd7178
    @mhsd7178 Před rokem +42

    Impressive. Any chance you could do a video where you go into more detail on how this works including how to work with the man pages?

  • @badgerint
    @badgerint Před rokem

    A very brave challenge indeed. Even more so with the senseless Yoda Notation.

  • @Don_XII
    @Don_XII Před rokem

    Haven't watched the video yet, but liked and comment already for the pain alone lol

  • @drizer4real
    @drizer4real Před rokem

    brilliant way to a) torture yourself and b) learn deeply about a subject. Love your channel !

  • @potatofuryy
    @potatofuryy Před rokem +5

    Man you’re making me want to get back to coding again

  • @_odo
    @_odo Před rokem +5

    Now do hardcore mode: switch OSes every time you get a compile error (Linux, macOS, Windows, FreeBSD, and then increasingly obscure Unixes in VMs)

  • @hbobenicio
    @hbobenicio Před rokem +1

    This is a really nice way to learn API's (and programming languages) by heart

  • @limesenpaiscomics3287

    So informative, thanks a lot!

  • @RichiAndiProject
    @RichiAndiProject Před rokem

    Ima download it thanks for sharing!!

  • @Erizo_
    @Erizo_ Před rokem +4

    ngl, easier than i expected, i was expecting like 1000 loc.

  • @phuctran25277
    @phuctran25277 Před rokem

    Nice video. I found your channels useful. You can improve your videos by adding intro or some sort of delays before the main content. I was shocked and completely caught off guard because the moment your video started you directly jumped into the main content at 00:00 immediately after the video is done loading. I have to scroll the video to the beginning because I did not catch what you said. Otherwise the content is good, keep up the good work!

  • @amisingh2366
    @amisingh2366 Před rokem

    This was awesome! More of that haha

  • @Quantum_Nebula
    @Quantum_Nebula Před rokem +1

    It's hella sadistic to even challenge yourself with this, especially on CZcams. Dang

  • @markay7311
    @markay7311 Před rokem

    Now, this is a video worth watching!

  • @berliangur
    @berliangur Před rokem +4

    It's like Dark Souls of Coding

  • @retrokoh1507
    @retrokoh1507 Před rokem

    Reads: "i START OVER every time i get a compiler error"
    Me: Grabs popcorn and gets comfy

  • @pendragonscode
    @pendragonscode Před rokem

    I read the title and I already knew what was coming.

  • @TheOriginalJohnDoe
    @TheOriginalJohnDoe Před rokem

    1:40 "0 > sfd"
    You sir, are playing with fire.

  • @user-hd7wd4nu1o
    @user-hd7wd4nu1o Před rokem

    Nice, brings back memories .... Did this ~35 years ago. Much harder in vi:) and using 2 vt100 terminals in a lab at 10pm at night.

  • @bloroxcleach896
    @bloroxcleach896 Před rokem

    coding a snake game but everytime you blink you have to start over

  • @yashumaurya4500
    @yashumaurya4500 Před rokem +1

    brother, what do you do for a living. if yt is your main work (full time) then what did you used to do before this ?

  • @steveokinevo
    @steveokinevo Před rokem

    A nice video man, your send and recv may not send all data on the first send / recv call, you need to handle that, nice intro all the same, well done.

  • @iwillburn
    @iwillburn Před rokem

    Hell yeah bruv! Let's goooooo!!!!!

  • @marianos63
    @marianos63 Před rokem

    This gentleman deserves a prize

  • @SkrtlIl
    @SkrtlIl Před rokem

    How would the good version of this code look for the client? Someone else mentioned polling for multiple connections on the server and resending a buffer (don't know why, I thought TCP takes care of that).

  • @T1MB05L1C3
    @T1MB05L1C3 Před rokem

    This is like the nuzlocke of coding

  • @mahdirahman8451
    @mahdirahman8451 Před rokem

    This is amazing 👏 🙌

  • @armazi2983
    @armazi2983 Před rokem

    Me: tries this challenge
    Also me: fucks up on main function declaration

  • @blackbriarmead1966
    @blackbriarmead1966 Před rokem

    This gives me flashbacks to my "Intro" to computer systems class. I had to make a multithreaded socket server for file transfer. took at lest 24 man hours

  • @bernardev3
    @bernardev3 Před rokem +1

    Imagine doing this challenge with an really big application, it might take some years to complete :v

  • @jojo150393
    @jojo150393 Před rokem

    Challenge with a friend: every compile error, the guy have to drink a beer

  • @perfectionbox
    @perfectionbox Před rokem +1

    A friend of mine took the challenge, he's still at it and it's been three years 😂

  • @LegendKopper
    @LegendKopper Před 5 měsíci

    I am a software engineer in a high level language (javascript/typescript) and it's always shocking / fascinating how little I understand watching these videos. Props to all C programmers out there

  • @sapphie132
    @sapphie132 Před rokem

    Why was my first reaction to the description of the challenge, "hey, that seems fun"?

  • @jflow922
    @jflow922 Před rokem

    This is a coding project nuzlocke

  • @excuseonme
    @excuseonme Před rokem

    You just earned a new sub 😂

  • @CallousCoder
    @CallousCoder Před rokem +37

    Kudos! Sadomasochistic challenge.
    But you didn’t do it properly (shortcut 😊) because this server only accepts one client. You need to either hand it of to select() or a pthread from a pool 😂 And you send and you do not check whether all bytes were sent and if not send the remainder until 0 bytes are send.

    • @LowLevelLearning
      @LowLevelLearning  Před rokem +52

      something something works on my computer

    • @CallousCoder
      @CallousCoder Před rokem +2

      @@LowLevelLearning try connecting 2 clients simultaneously see if it still works for both of them 😂Although that could be a challenge with such a short message.
      But that send bug I came across in a commercial bokking system that booked tickets. And sometimes it would hang and the whole client hung - waiting for the ticket booking to be confirmed.
      I disassembled the code read it and instantly saw that blatant bug. Reported it to the manufacturer in Sri Lanka and they were like: “it works here in unit test, it’s no bug!”
      Well do’t do that to me because I get very annoyed 😅 “Of course it works when you test it on a high speed local network let alone on loop back interface! But try it in the real world with slower lines, where did you get your degree? The useless Uni?”
      So I actually patched the binary code with a hack hook. And proved it to them with screenshots. And when I proved it to that engineer’s manager - who happened to visit our office the next week. And I told what an idiotic useless attitude this guy had, he got fired by him over the phone… that was not what I wanted.
      Now that single connection bug I ran into as well at a company we were doing a technical verification for a product a client of us wanted to buy.
      I see the server code and I say to my manager: “let’s have some fun”
      I opened a telnet to that server and kept its socket alive.
      The engineer comes and starts test run and it doesn’t end (waits for connection). We hear him go: “huh? What? Huh? Well I think we fucked up some code, time to restore everything!”
      We looked at each other and immediately made a note in our report to not use Cegelec as their IT partner because they obviously didn’t write quality code nor understood their own solution.
      The funny thing is that I too ran into these things learning socket programming back in the mid 90s. So I know what to look for, but Fucking up during learning is fine. Making this blunders in production code is unforgivable.

    • @toastea4987
      @toastea4987 Před rokem

      @@CallousCoder Dude its a coding challenge not an enterprise program

  • @ashajjar
    @ashajjar Před rokem

    how do you know which section to call from the man pages? :/

  • @scriblestingray5713
    @scriblestingray5713 Před rokem

    Why. I haven’t even watched the video, but seeing that title makes me want to die.

  • @HenokJackson
    @HenokJackson Před rokem

    At 7:03 did you try type casting & client_info to (struct sockaddr*)?

  • @kawaiibunnypop5545
    @kawaiibunnypop5545 Před rokem

    This is the best free software Ive seen. Respect.

  • @stefan429
    @stefan429 Před rokem

    this is the low level masochism i fuck with

  •  Před rokem +2

    Can we go async next time? Awesome tutorial.

  • @avashurov
    @avashurov Před rokem

    Reminded my how we had to write c code on the paper in collage for exam…
    Now double challenge, make it compile and run with no errors on Linux, MAC, and windows

  • @hypocritical7379
    @hypocritical7379 Před rokem

    This is literal torture

  • @MuhammadAhmedBilali
    @MuhammadAhmedBilali Před rokem +1

    Did you close sfd at the end of server.c main?

  • @vmannn4259
    @vmannn4259 Před rokem

    "Step 1: Be the compiler"

  • @abeard1
    @abeard1 Před rokem

    This was nerve-wracking

  • @Burgo361
    @Burgo361 Před rokem

    This challenge is awesome, and I both want to try it and fear it haha

  • @whythisisntchanging
    @whythisisntchanging Před rokem

    nice cut at 8:24 :) headers magically include themselves?

  • @Artenesama
    @Artenesama Před rokem

    Great vídeo!

  • @sorek__
    @sorek__ Před rokem +7

    Great challenge, you are definitely very good programmer.
    Shame it's very complicated and hard to follow for someone who doesn't know what this stuff does!

    • @LowLevelLearning
      @LowLevelLearning  Před rokem +7

      Sorry!

    • @sorek__
      @sorek__ Před rokem +7

      @@LowLevelLearning Don't be sorry for being good!

    • @deang5622
      @deang5622 Před rokem

      A good programmer doesn't waste valuable time deleting code because they made a harmless mistake.

  • @setitthen
    @setitthen Před rokem +1

    Great channel ....can you do something on passing array using pointers to an address. And circular buffers for data logging applications. Thank you.

  • @embedyt
    @embedyt Před rokem

    i dont even know anything about c++ i just like watching it

  • @okie9025
    @okie9025 Před rokem +10

    Nice!

  • @ayman436
    @ayman436 Před rokem +1

    The Dark Souls of programming

  • @enriquedelacal2814
    @enriquedelacal2814 Před rokem +2

    More C videos please

  • @huntabadday2663
    @huntabadday2663 Před rokem +1

    He. He did it! He made a program work first try!

  • @alfredomenezes8814
    @alfredomenezes8814 Před rokem +1

    Would be intersting to see something like this with Rust too!

  • @Siger522
    @Siger522 Před rokem +8

    Does using a checker count as getting compiler errors?

    • @dardevelin
      @dardevelin Před rokem +3

      Yes Obvi. You need to be able to write in pen and paper and no googling :D

  • @BalloStudios
    @BalloStudios Před rokem +1

    What is a socket server?

  • @thomas_w
    @thomas_w Před rokem

    Why do you always write
    if(0 > expr)? I mean it works the same, but I and also everybody i know would write something like if(expr < 0), so the expression before.
    But still a great video anyway.

  • @mah4i
    @mah4i Před rokem

    i took long breaks over writing ssl and socket networking projects and i'm in one of those breaks rn, it is taking 2 months, i think im not gonna code again... help me

  • @moyasardev
    @moyasardev Před 11 měsíci

    i was getting a segmentation fault for hours and was going crazy, i just figure it out, turns out i can't pass a string through a function, i have to let the user input a string using get_string() function, KILL ME PLEASEEEEEEE

  • @TornTech1
    @TornTech1 Před rokem +1

    Im looking for some guidance... I am a professional Web Backend C# developer. But in the evenings I'm wanting to dabble in embedded/bare metal programming as its quite distant from the usual stuff I do every day in C#...(The idea of attempting to write my own OS one day is quite appealing!)
    I've been binge watching your videos and love the channel and your content! but I am conflicted between focusing my effort on learning and mastering Rust, Vs C. I Was hoping to hear some opinions from yourself and the community on what people think, and if you had to do it over again... what would you pick as your main weapon of choice for this area of development?

    • @LowLevelLearning
      @LowLevelLearning  Před rokem +1

      I’ll be doing a video on this first but the short version is if you’re new to this world, learn how things work with C first. It’s the best way to learn how computers work (albeit the process is a bit painful :) )

  • @paherbst524
    @paherbst524 Před rokem +3

    Only using man pages?? Isn't that the norm? That should be everyone's first reference.

  • @Red4mber
    @Red4mber Před rokem

    Satan be like : Now do that in Rust

  • @sixty502
    @sixty502 Před rokem

    Why does your window manager look like imgui?

  • @johntheawsomeful
    @johntheawsomeful Před rokem

    These are my favorite

  • @manuindenwolken
    @manuindenwolken Před rokem

    Please do this in Rust and expand the condition for starting over to compilation warnings.

  • @m1geo
    @m1geo Před 10 měsíci

    You could be stylising Low Level Gang as "L2G" pronounced "L-squared G". lol

  • @aakarshan4644
    @aakarshan4644 Před rokem +3

    oh shit ... this sadomasochistic method is so fucking useful to increase accuracy in coding problems lamo .. thanks man :)

    • @LowLevelLearning
      @LowLevelLearning  Před rokem +1

      this is the way

    • @CallousCoder
      @CallousCoder Před rokem

      My dad and even a colleague 10 years my senior couldn’t even compile to see if something was correct or not. Because compiling took too much resources from daily batch processing. So compiles were queued to be done after business hours.
      So fucking up meant losing a whole day.
      Im a very decent programmer but I do need iterate quickly 😄 I couldn’t do that.

  • @31redorange08
    @31redorange08 Před rokem

    Putting a literal on the lhs of a comparison operator should be a compilation error.

  • @Markyroson
    @Markyroson Před rokem

    (Before starting vid) This would SUCK. You're braver than I am rofl.

  • @durgeshchauhan9773
    @durgeshchauhan9773 Před rokem

    Best of the best

  • @Username9182736451
    @Username9182736451 Před rokem +1

    Amazing. But why does it have to be so hard? I wish somebody would write a single function that returns a file descriptor you can read and write, that takes a text specifier with name=value, pairs. It could read and write to tcp, udp, rs232, file, raw socket, can, as a client or server, and if the specifier is null, it pops up a gui to let you choose. The last 2 years I've had to read and write all those things and just getting a connection is so error prone and I've wasted an embarrassing amount of time.

    • @Acorn_Anomaly
      @Acorn_Anomaly Před rokem

      Because they're not all equivalent. The ultimate goal - moving a stream of bytes somewhere - is the same, but there's different things involved with getting that pipe set up for each of those types, and your program has to be able to handle those.
      It might be possible to write some sort of wrapper to take care of all of the lower level details for you, but that would just result in creating something incredibly fragile that breaks if you breathe on it wrong. And worse, it won't be able to tell you why it broke. After all, the interfaces for ALL types would have to be the same, if you want the same code to just "work" for each type. You can't have an interface for an rs232 connection return "unable to connect to IP address, network not available", which means you can't actually have an error code saying the network isn't available even if you're actually connecting to a network that isn't available. The only thing you would get is success/failure, with no reason why. Did you type a filename wrong? Did you type an incorrect domain name? Did you use the wrong RS232 port? No idea, who knows!

  • @realtuber6522
    @realtuber6522 Před rokem

    File descriptors don't close themselves, and recv doesn't NUL terminate it's output.
    Now also delete your code on undefined behaviour, and resource leaks :^)