coding in C but I start over for every compiler error
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
follow me on twitter please 👉 👈 twitter.com/lowlevellearni1
Hey man, Do you run your code through WSL?
Hello, i have one question, i hope you may take an answer on it. What font do you use in this video?
Next challenge: repeat this with
echo | gcc -x
@@gameplayyt504 It's native Linux
Now onto the hard mode, compile with: -Wall -Wextra -pedantic -Werrors -Wconversion
I had to make sure the video adhered to the CZcams under 24 hour guideline LOLOL
I preffer -pedantic-errors -fstack-protect-all -std=c89
@@TheMLover hahahaha... c89 lol
@@KaranveerSingh97 the OG mode
@@KaranveerSingh97 LooL not with c89 😂 this would be getting ridiculous
I learned a great practice: "TODO: Make code good"
Imma put this after every line of code now!
YOURE LEARNING FROM THE BEST
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.
// do client stuff
Don’t repeat yourself. Put all the code inside a single todo block
This is honestly better than watching an hour long tutorial of an introduction for writing sockets in C.
Could you explain to me what the application of a program like this is ?
@@lmaox265 To run a server, basically.
-Wall -Werror
HARD MODE
@@LowLevelLearning nah hard mode is with -Wextra
You forgot -pedantic
-Weverything
-WhatTheFack
"Warnings are not errors"
Only runtime can tell... ; )
Truuuuuuuuw
Great video idea. I especially like the "no outside resources" part. This was the default up to like 2005 for most of us :D
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!
_MAN_
You inspired me to make a calculator interface in c++ with qt designer, but everytime its ugly i retype everything, wish me luck
See you in a few years LOL
Hahaha you made me chuckle man!
@@LowLevelLearning Lmao
Have you finished?
I have begun to love this channel so much, some more low level content would be fucking amazing!
I am rather impressed. Not many people have the courage to do such challenge with such rules!
I called it the sadomasochistic challenge! 😃
What challenge? He basically copied from the man docs.
@@Dyanosis he knew much more than that
[edit: I fixed a poor typo error I made]
It's a pointless challenge: it achieves absolutely nothing.
@@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.
very cool idea and a clever gimmick! hope you do more of these
With your videos my learning curve will shrink drastically. Thank you.
This feels like a Speedrun but every error is a huge timeloss so you reset
Yeah I also thought of steel soul/iron man programming
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.
Thank you for your kind words!
I just know this is a GREAT way to learn ! 😂 Leaving a comment so I can come back to this when I get off
Learnt a lottt
Pls do these type of challenges moreeeee.
This was an excellent video! Thanks. I need to try this sometime as it will probably improve my programming skills.
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.
Man youre crazy .)) Love your videos
I don't think I ever felt so stressed out from watching someone code. hahaha
LOW LEVEL GANG! This is what's up! Great video as always my dude. htons time.
GANG GANG GANG
It is genuinely so nice to see someone else using wmi3, like seriously it really made my day lol
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?
Sure
yeah, i was shocked when he pulled up documentation from a man page
A very brave challenge indeed. Even more so with the senseless Yoda Notation.
Haven't watched the video yet, but liked and comment already for the pain alone lol
brilliant way to a) torture yourself and b) learn deeply about a subject. Love your channel !
Man you’re making me want to get back to coding again
Now do hardcore mode: switch OSes every time you get a compile error (Linux, macOS, Windows, FreeBSD, and then increasingly obscure Unixes in VMs)
This is a really nice way to learn API's (and programming languages) by heart
So informative, thanks a lot!
Ima download it thanks for sharing!!
ngl, easier than i expected, i was expecting like 1000 loc.
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!
This was awesome! More of that haha
It's hella sadistic to even challenge yourself with this, especially on CZcams. Dang
Now, this is a video worth watching!
It's like Dark Souls of Coding
Reads: "i START OVER every time i get a compiler error"
Me: Grabs popcorn and gets comfy
I read the title and I already knew what was coming.
1:40 "0 > sfd"
You sir, are playing with fire.
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.
coding a snake game but everytime you blink you have to start over
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 ?
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.
Hell yeah bruv! Let's goooooo!!!!!
This gentleman deserves a prize
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).
This is like the nuzlocke of coding
This is amazing 👏 🙌
Me: tries this challenge
Also me: fucks up on main function declaration
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
Imagine doing this challenge with an really big application, it might take some years to complete :v
Challenge with a friend: every compile error, the guy have to drink a beer
A friend of mine took the challenge, he's still at it and it's been three years 😂
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
Why was my first reaction to the description of the challenge, "hey, that seems fun"?
This is a coding project nuzlocke
You just earned a new sub 😂
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.
something something works on my computer
@@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.
@@CallousCoder Dude its a coding challenge not an enterprise program
how do you know which section to call from the man pages? :/
Why. I haven’t even watched the video, but seeing that title makes me want to die.
At 7:03 did you try type casting & client_info to (struct sockaddr*)?
This is the best free software Ive seen. Respect.
this is the low level masochism i fuck with
Can we go async next time? Awesome tutorial.
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
This is literal torture
Did you close sfd at the end of server.c main?
"Step 1: Be the compiler"
This was nerve-wracking
This challenge is awesome, and I both want to try it and fear it haha
Do itttttt
nice cut at 8:24 :) headers magically include themselves?
Great vídeo!
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!
Sorry!
@@LowLevelLearning Don't be sorry for being good!
A good programmer doesn't waste valuable time deleting code because they made a harmless mistake.
Great channel ....can you do something on passing array using pointers to an address. And circular buffers for data logging applications. Thank you.
Sure thing!
i dont even know anything about c++ i just like watching it
Nice!
Thanks!
The Dark Souls of programming
More C videos please
He. He did it! He made a program work first try!
Would be intersting to see something like this with Rust too!
Does using a checker count as getting compiler errors?
Yes Obvi. You need to be able to write in pen and paper and no googling :D
What is a socket server?
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.
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
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
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?
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 :) )
Only using man pages?? Isn't that the norm? That should be everyone's first reference.
Satan be like : Now do that in Rust
Why does your window manager look like imgui?
These are my favorite
Please do this in Rust and expand the condition for starting over to compilation warnings.
You could be stylising Low Level Gang as "L2G" pronounced "L-squared G". lol
oh shit ... this sadomasochistic method is so fucking useful to increase accuracy in coding problems lamo .. thanks man :)
this is the way
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.
Putting a literal on the lhs of a comparison operator should be a compilation error.
(Before starting vid) This would SUCK. You're braver than I am rofl.
Best of the best
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.
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!
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 :^)