Easy Networking in C (libcurl)

  Рет қаралды 66,489

Jacob Sorber

Jacob Sorber

Күн бұрын

Пікірлер: 119
@fablesfables
@fablesfables 4 жыл бұрын
Hey man, just want to say as fellow university student that programs in C/C++ every single day, your youtube videos have been gold for bringing some 21st century C knowledge onto youtube. The way you layout your videos and your explanations with clear concise examples allow me to really understand the concepts well and have enough to get going myself. Thank you so much and keep making awesome content!!
@JacobSorber
@JacobSorber 4 жыл бұрын
You're welcome! Glad I could help.
@critic7337
@critic7337 3 жыл бұрын
Great video - but to any students watching, don't let his rant about "doing it yourself" fool you - 99% of professional developers do not write their own HTTP/FTP/etc. clients for new projects. Using a library for something like this is normal and good, especially one that is as well documented and tested as libcurl.
@fernandoalencar3767
@fernandoalencar3767 2 жыл бұрын
Wow super quick and fast for newbies like me to learn.. Of course there are cons and pros to using this library but for beginners in C that are still exploring the language, it’s really amazing!
@srglmr
@srglmr 4 жыл бұрын
Your channel is a treasure , thank you
@JacobSorber
@JacobSorber 4 жыл бұрын
Welcome! Glad you're enjoying it.
@marusdod3685
@marusdod3685 4 жыл бұрын
if you execute the curl command with the option --libcurl it will dump the source code
@JacobSorber
@JacobSorber 4 жыл бұрын
Oooh...I didn't realize that. Thanks!
@rafalmichalski4893
@rafalmichalski4893 4 жыл бұрын
Yes really handy feature
@jimmymontenegro8517
@jimmymontenegro8517 2 ай бұрын
Gracias, me va a servir mucho para lo que estoy aprendiendo.
@lordadamson
@lordadamson 3 жыл бұрын
Your videos also serve as references :D Here I am after several months coming back to this video because I'm implementing something that needs libcurl. You sir are awesome :D
@JacobSorber
@JacobSorber 3 жыл бұрын
Thanks, Adam. Glad they're still helpful.
@luismex5575
@luismex5575 4 жыл бұрын
Please make more videos about this... they are great
@rishabhanand4270
@rishabhanand4270 3 жыл бұрын
Okay, so by default any response headers are omitted, that's really handy. Not many people need to read GET 200 OK HTTP/1.1, that is really useful. If you need it, you can use it. That's probably why those functions are having _easy_ in them. Beautiful library.
@ytsgyan2816
@ytsgyan2816 Жыл бұрын
Hi Jacob,also, please do mention online tutorial for beginner to advanced lesson of using libcurl in C.
@taskinabdur-rahman3487
@taskinabdur-rahman3487 2 жыл бұрын
This channel is incredible. Great work keep it up!
@jasonzurlo1543
@jasonzurlo1543 3 жыл бұрын
How do you get the curl library? I went on the website, but I can only find an executable curl program.
@user-ej7ss8ei2g
@user-ej7ss8ei2g 3 жыл бұрын
I love your videos so much, seriously. Your list and queue videos are really fun as well. libcurl has got to be one of the most messy or perhaps OVERLY abstracted APIs ever. It just ends up super non-intuitive to me.
@JacobSorber
@JacobSorber 3 жыл бұрын
Not as "easy" as you would like? 😀 Thanks for the support.
@AntonioAstorino
@AntonioAstorino 3 жыл бұрын
I pushed the "like" button at 1:07 - LOL
@banshiaryal7620
@banshiaryal7620 4 жыл бұрын
Great work as usual. Your videos are so helpful. Would you mind syncing your content over on LBRY? Trying to stay away from KZbin.
@rafalmichalski4893
@rafalmichalski4893 4 жыл бұрын
Nice video Jacob as always. I have question could you make video based on curl to show how to use some example REST API with post / get / put methods ?
@JacobSorber
@JacobSorber 4 жыл бұрын
Sure. I'll add it to the future video topic list.
@deepakmbirajdar4716
@deepakmbirajdar4716 3 жыл бұрын
@@JacobSorber Is this available? and please let us know how to get status code.
@JacobSorber
@JacobSorber 3 жыл бұрын
@@deepakmbirajdar4716 Is the source code available? Yes, through Patreon. And, by "status code" do you mean the HTTP status code?
@deepakmbirajdar4716
@deepakmbirajdar4716 3 жыл бұрын
@@JacobSorber yup
@comprehensivemuskrat
@comprehensivemuskrat 4 жыл бұрын
When you’re writing a callback or interacting with a callback heavy library, what’s a fast way to find the callback signature and make sure you’re getting the signature right?
@JacobSorber
@JacobSorber 4 жыл бұрын
The signature should be listed in the library documentation. If not, you can check the header file where the function that takes the callback is defined. The signature should be there, too.
@Raspredval1337
@Raspredval1337 4 жыл бұрын
every function signature is a data type, so if ur IDE shows the type aliases, it would show u the required function signature
@krystof7059
@krystof7059 4 жыл бұрын
video on linking libraries please? :D I know how to link in ide but not in code editor... Do you have all your library files in same folder?
@vikramfugro3886
@vikramfugro3886 4 жыл бұрын
Yeah , LD_LIBRARY_PATH, RUNPATH, RPATH, LD_PRELOAD,
@krisdoe
@krisdoe 4 жыл бұрын
Nice video. Indeed, this is the easy way to do quick and dirty networking in C. One question still remains - is how portable is thit between different Linux distributions? I already tried to use it on DEB-based ones (works great). But for RPM-based, somehow is causing troubles finding the library. It would be nice if get better explanation how we can make sure the application we write is portable.
@JacobSorber
@JacobSorber 4 жыл бұрын
Hmm... I haven't seen that, but then again, these days most of my work is either on macOS or ubuntu (seems to work fine on both). If you can send me more details about the issue you're seeing, I'll take a look. Always looking for interesting video ideas. Thanks.
@krisdoe
@krisdoe 4 жыл бұрын
@@JacobSorber I decided to drop you a mail. I don't want to flood the comment section. I hope you don't mind. Maybe after everything is clarified we could share the information with everybody here.
@bobtournoux1825
@bobtournoux1825 3 жыл бұрын
The curl library is certainly a life saver when there isn't time to do the low level socket stuff. Do you have any idea how much of a performance hit using curl instead of the low level socket programming might be? For my case it would be just using curl to to some simple GET and POST calls, but there might be 10 to 20 calls per second. Just wandering if using curl can handle that kind of load.
@OrchidAlloy
@OrchidAlloy 2 жыл бұрын
It's not as if it's gonna be slower than every Node JS app people use nowadays
@azsxw2
@azsxw2 3 жыл бұрын
This is awesome!
@dhanashreebhoyar55
@dhanashreebhoyar55 2 жыл бұрын
Can I use libcurl in Apache web server module? I tried but I am always getting undefined reference to libcurl API. Can you please make videos on apache+libcurl.
@subhashsarangi
@subhashsarangi 4 жыл бұрын
Awesome video... However I'm confused by the usage of curl_easy_setopt function. On line 33 the 3rd arg to this function was a string. But on line 34 it was a function. How is that possible in C?
@JacobSorber
@JacobSorber 4 жыл бұрын
Thanks. They're both pointers. A character pointer and a function pointer are both just addresses. But, this function is implemented as a variadic function (kind-of like printf). I have a video on variadics, if you're interested.
@subhashsarangi
@subhashsarangi 4 жыл бұрын
@@JacobSorber Thank you.
4 жыл бұрын
@@JacobSorber I mean, the function may receive void*, but how does curl knows it's a char* or a function pointer?
4 жыл бұрын
I guess it depends on the opt argument, but it still may get in trouble if the pointer passed is not of a type it expects.
@JacobSorber
@JacobSorber 4 жыл бұрын
It determines what it is based on the option you specify. For URL, it looks for a string. For the other, it looks for a function pointer.
@eliaspfeffer
@eliaspfeffer 3 жыл бұрын
THIS IS GREAT! THANKS A LOT! WOOOOOOOOW YEAH
@subhraneelmukhopadhyay309
@subhraneelmukhopadhyay309 Жыл бұрын
I'm getting this error "Makefile:10: *** missing separator. Stop." when i type make
@larrysmall3521
@larrysmall3521 Ай бұрын
Sounds like you have a space instead of a Tab on line 10 in the makefile.
@lorensims4846
@lorensims4846 3 жыл бұрын
Wheee! "easy"!!
@ColonelPuttu
@ColonelPuttu 2 жыл бұрын
just found out a *legendary* channel very helpful thanks
@piecepaper2831
@piecepaper2831 3 жыл бұрын
but how i install curl and link it.
@axelbagi100
@axelbagi100 3 жыл бұрын
Hey man, I need some help The simple curl_easy_setopt(curl, CURLOPT_URL, "https:....") throws an unsupported protocol error I have installed libcurl this way: Downloaded the latest zip, extracted it In the extract location in cmd (Im on win10) used this code: cmake -G "MinGW Makefiles" -S . -B . -DCMAKE_INSTALL_PREFIX=F:\MinGW\mingw64\x86_64-w64-mingw32 Then *mingw32-make all* and *mingw32-make install* Everything is fine but the program doesnt work If I simply use curl from the cmd like this: *curl CURLOPT_URL **www.youtube.com* it works fine What could be a problem? Cant find an answer anywhere
@Massimus888
@Massimus888 3 жыл бұрын
Thanks! Do you recommend libxml2 for parsing the html document?
@Ryan-mn6xs
@Ryan-mn6xs 4 жыл бұрын
Great video as usual! Any plans to do one on Toolchains?
@JacobSorber
@JacobSorber 4 жыл бұрын
Thanks. Are you interested in any specific toolchain?
@Ryan-mn6xs
@Ryan-mn6xs 4 жыл бұрын
@@JacobSorber Kind of niche, but musl on mips. Linux to FreeBSD would be interesting as well. More generically the idea of cross-compilation and emulation (qemu) would be a cool topic.
@elrayonegro100
@elrayonegro100 4 жыл бұрын
Where can I get that shirt? Excelent video 👌
@JacobSorber
@JacobSorber 4 жыл бұрын
teespring.com/stores/jacob-sorbers-store
@lordr021
@lordr021 2 жыл бұрын
I have the json, how to iterate response string readBuffer, containing a json -> curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
@lowrhyan567
@lowrhyan567 3 жыл бұрын
Wheres the documentation of libcurl?
@smalinux
@smalinux 4 жыл бұрын
You are amazing! thank you
@JacobSorber
@JacobSorber 4 жыл бұрын
You're welcome. Glad I could help.
@lordadamson
@lordadamson 4 жыл бұрын
that was awesome :D
@JacobSorber
@JacobSorber 4 жыл бұрын
Thanks, Adam.
@vitacell1
@vitacell1 3 жыл бұрын
Can be great some simple game in terminal with p2p game networking.
@amanrohilla4435
@amanrohilla4435 3 жыл бұрын
I'm getting an error with url, SSL certificate problem: unable to get local issuer certificate how to solve it. I'm using windows
@anistatus4u421
@anistatus4u421 2 жыл бұрын
thats openssl problem
@hasithapathirage3830
@hasithapathirage3830 4 жыл бұрын
How can we cross compile libcurl to work in ARM architecture
@JacobSorber
@JacobSorber 3 жыл бұрын
I haven't tried this, but it would surprise me if someone hasn't. Socket code is fairly portable.
@hasithapathirage3830
@hasithapathirage3830 3 жыл бұрын
@@JacobSorber yeah I got it done, thank you for the reply
@Fraket
@Fraket 3 жыл бұрын
Thanks for this. Great video. Just bought one of those shirts, btw :)
@JacobSorber
@JacobSorber 3 жыл бұрын
Thanks! Glad I could help you upgrade your wardrobe. 😀I appreciate the support.
@cassiewinger7041
@cassiewinger7041 4 жыл бұрын
Hi, thanks for the tutorials. #awesome. can you make a tutorial about a simple encrypted chat? just a server an a client having sending and receiving encrypted texts? thanks.
@JacobSorber
@JacobSorber 3 жыл бұрын
Interesting. Maybe. What sort of encryption would you be interested in? Just something symmetric (AES?) with a shared key, or are looking for full Public Key/Private Key stuff?
@JohnDoe-ym2oy
@JohnDoe-ym2oy 3 жыл бұрын
@@JacobSorber thats sounds fun!
@juuamjskn2420
@juuamjskn2420 4 жыл бұрын
Thanks!
@JacobSorber
@JacobSorber 4 жыл бұрын
You're welcome.
@willmurphy8650
@willmurphy8650 4 жыл бұрын
nice video
@JacobSorber
@JacobSorber 4 жыл бұрын
Thanks.
@user-mr3mf8lo7y
@user-mr3mf8lo7y Жыл бұрын
All good. Buttttt linking Curl statically with your program is really pain. You have been warned.
@maqusss
@maqusss 4 жыл бұрын
Is there a problem with print because the charset is UTF-8 ?
@Raspredval1337
@Raspredval1337 4 жыл бұрын
ASCII translates into the UTF8 without any change, so every English text is ok, but local characters such as Cyrillic or Eastern Europe would be represented as character pairs or triplets, so standard printf would just type some random stuff instead.
@deepakmbirajdar4716
@deepakmbirajdar4716 3 жыл бұрын
How to disable printing the response automatically. How do we get the status code.
@JacobSorber
@JacobSorber 3 жыл бұрын
For disabling the printing, just remove the print statements. I'm doing the printing, not libcurl. For the response code, check this out. curl.se/libcurl/c/CURLINFO_RESPONSE_CODE.html
@deepakmbirajdar4716
@deepakmbirajdar4716 3 жыл бұрын
@@JacobSorber I mean at this point 6:15
@JacobSorber
@JacobSorber 3 жыл бұрын
@@deepakmbirajdar4716 Ok. The video shows you how to specify a "write function" and that allows you to replace the default behavior (turning it off).
@mohdatishan2090
@mohdatishan2090 2 жыл бұрын
Link not working! Low level socket programming link?
@JacobSorber
@JacobSorber 2 жыл бұрын
Weird. Maybe YT changed the link? It's pretty old. I just updated. Let me know if that works for you.
@mohdatishan2090
@mohdatishan2090 2 жыл бұрын
@@JacobSorber Yeah, that works! BTW Huge Respect for replying....
@SimGunther
@SimGunther 4 жыл бұрын
Postman and Insomnia are capable of creating c code that calls libcurl functions based on endpoint data in the postman request. Learn how the libraries work through documentation first before naively using this generated code in your project.
@ButIfWeSurvive-WeHereInTheEnd
@ButIfWeSurvive-WeHereInTheEnd Жыл бұрын
is not working (link issue)
@leokiller123able
@leokiller123able 3 жыл бұрын
If you don't want to get annoyed by the "easy" you can just do #define curl_ curl_easy_
@judedavis92
@judedavis92 3 жыл бұрын
Are you into the new M1 Macs?
@JacobSorber
@JacobSorber 3 жыл бұрын
Too soon to say. There have been some benefits to having my Linux boxes and Macs on the same CPUs. I hope we don't lose ground there, but diversity in the market can be a good thing. So, I'm cautiously optimistic, and hoping for the best.
@judedavis92
@judedavis92 3 жыл бұрын
@@JacobSorber hey I was literally watching one of your early websockets videos. Nice channel, keep it going.
@ladyViviaen
@ladyViviaen 4 жыл бұрын
c-chad
@dracla26
@dracla26 3 жыл бұрын
You are such a badass.
@JacobSorber
@JacobSorber 3 жыл бұрын
😀
@geethanisamanthilake9635
@geethanisamanthilake9635 Жыл бұрын
Thank you
@jeelpatel4121
@jeelpatel4121 Жыл бұрын
its not work on localhost
@user-sl6gn1ss8p
@user-sl6gn1ss8p 4 жыл бұрын
This has nothing to do with the topic at hand, but does anyone know of some examples of test driven development in practice, at some depth? I like the idea but have a hard time seeing how one actually goes about it : p
@thinking-laaf
@thinking-laaf 3 жыл бұрын
FTP isn't secure, so it doesn't matter the password is secure or not.
@JacobSorber
@JacobSorber 2 жыл бұрын
Very true.
@georgehaake
@georgehaake 4 жыл бұрын
t-shirt source please.
@JacobSorber
@JacobSorber 4 жыл бұрын
You can get it from the merch store, should show up right under the video.
@georgehaake
@georgehaake 4 жыл бұрын
@@JacobSorber Don't see it. Found it via search.
@JacobSorber
@JacobSorber 4 жыл бұрын
@@georgehaake So, strange. I wonder why some people don't see it on YT. Glad you were able to find it. Thanks for the support.
@OrchidAlloy
@OrchidAlloy 2 жыл бұрын
It's almost as if curl is making fun of you for doing things the easy way
@LinucNerd
@LinucNerd 4 жыл бұрын
Your indentation makes me sad )': *cry*
@pixelPlex
@pixelPlex 4 жыл бұрын
Very useful for developers of C libraries to keep in mind that there are different programming languages other than C that can use C libraries (eg Kotlin - kotlinlang.org/docs/reference/native/c_interop.html ). C library developers need to design APIs in a way that can be usable for other programming languages (eg don't use macros as part of the public API). Here is a sample project that uses libcurl: gitlab.com/napperley/curl-example
@noxabellus
@noxabellus 4 жыл бұрын
Macro usage isnt going to stop anyone from making an ffi wrapper for your library; In fact there isnt really much you can do that precludes an ffi wrapper for your c library. The universal compatibility of C is exactly why other languages have ffi for it. On the contrary, you shouldn't hamper the lib consumer's experience in primary language just to simplify the process of writing a wrapper for it. Things like defines for constant expressions dont have good alternatives in C and you shouldn't avoid them. Translating them to the wrapper language is much simpler than working around the lack of them in c.
@radio_electronics4047
@radio_electronics4047 9 ай бұрын
This video is not that helpful because you do not store the data in a variable and are not able to use that data in the rest of your program, you just have it in a callback function. And getting that data into a variable is the most complicated part in libcurl.
@laptoprecaia.k.aagentsmith3328
@laptoprecaia.k.aagentsmith3328 3 жыл бұрын
.
@sheditz4962
@sheditz4962 3 жыл бұрын
@esgosar
@esgosar 2 жыл бұрын
clean this Mac screen
@ASAPSIDJ
@ASAPSIDJ 4 жыл бұрын
libcurl is bloated, too bad all the HTTP libraries suck
@user-ej7ss8ei2g
@user-ej7ss8ei2g 3 жыл бұрын
Yes
Fixed and Variable Length Arrays in C and C++
20:24
Jacob Sorber
Рет қаралды 45 М.
Why are Progress Bars Always Wrong? Progress Bar Example in C.
35:44
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 6 МЛН
How to Fight a Gross Man 😡
00:19
Alan Chikin Chow
Рет қаралды 13 МЛН
How To Choose Mac N Cheese Date Night.. 🧀
00:58
Jojo Sim
Рет қаралды 90 МЛН
When u fight over the armrest
00:41
Adam W
Рет қаралды 31 МЛН
Networking in C | Sockets
42:27
Alex The Dev
Рет қаралды 1,7 М.
Just enough assembly to blow your mind
29:31
Kay Lack
Рет қаралды 140 М.
Make your Data Type more Abstract with Opaque Types in C
13:41
Jacob Sorber
Рет қаралды 51 М.
How to write a multithreaded server in C (threads, sockets)
14:30
Jacob Sorber
Рет қаралды 137 М.
Where is Rust being used?
11:46
Let's Get Rusty
Рет қаралды 124 М.
The Inline Keyword in C.
16:18
Jacob Sorber
Рет қаралды 58 М.
How one thread listens to many sockets with select in C.
12:01
Jacob Sorber
Рет қаралды 100 М.
Running a Buffer Overflow Attack - Computerphile
17:30
Computerphile
Рет қаралды 2 МЛН
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 6 МЛН