News for hackers. Stuff that matters.
Re:Beej updated the classic Linux network programming guide by biohax2015 on Wednesday July 20, 2022 @11:46AM (#32167436)
Do we need to know C to use this?
Re:Beej updated the classic Linux network programming guide by jey on Wednesday July 20, 2022 @01:35PM (#32169337)
No, not necessarily. You can use these APIs directly from many different languages. For example, Python has 'socket'[1], Ruby has 'socket'[2], Julia has 'Sockets'[3], PHP has 'socket_*'[4].

1. https://docs.python.org/3/library/socket.html

2. https://ruby-doc.org/stdlib-2.5.3/libdoc/socket/rdoc/Socket....

3. https://docs.julialang.org/en/v1/stdlib/Sockets/

4. https://www.php.net/manual/en/ref.sockets.php

Re:Beej updated the classic Linux network programming guide by freedomben on Wednesday July 20, 2022 @04:41PM (#32172014)
I went through a ton of linux socket tutorials that were in C using that Ruby Socket library. Highly recommend!

Edit: This is a more up to date link. I don't think the library has changed since 2.5.3, but I usually try to look at latest documentation: https://ruby-doc.org/stdlib-3.1.2/libdoc/socket/rdoc/Socket....

Re:Beej updated the classic Linux network programming guide by tempusr on Wednesday July 20, 2022 @11:51AM (#32167504)
It uses the gcc compiler so C, or C++ can be applicable.

That being said, this book teaches network programming from the ground up so I would recommend understanding how to compile and output C code, then go through the book.

If you run into keywords, or syntax that you are not familiar with, just google it, and then keep working through the examples.

Mind you, the key takeaways from this book are not how to network practice IN C, but general practices. This knowledge can be applied to plenty of other languages such as Rust.

Re:Beej updated the classic Linux network programming guide by gre on Wednesday July 20, 2022 @01:05PM (#32168796)
You can learn C at the same time.
Re:Beej updated the classic Linux network programming guide by lprd on Wednesday July 20, 2022 @01:09PM (#32168852)
Besides the classic C book by K&R, what are some more modern C books that the HN community vouch for?
Re:Beej updated the classic Linux network programming guide by gre on Wednesday July 20, 2022 @01:14PM (#32168941)
My favorite C programming book was Expert C Programming by Peter van der Linden, mainly for the method of reading any C declaration and for teaching me the difference between libc calls vs syscalls. There's also a book called Modern C by Jens Gustedt from 2020 that I have and is more beginner friendly.

The way I learned C is I printed out the Beej's guide client/server code and walked around staring at it until it made sense. (That and compiling/running it and looking up functions in the man pages.)

Re:Beej updated the classic Linux network programming guide by macintux on Wednesday July 20, 2022 @02:12PM (#32169901)
Expert C Programming is brilliantly written. I recently bought another copy because I lost mine; I don’t actually need it, but it’s a fun read regardless.
Re:Beej updated the classic Linux network programming guide by beej71 on Wednesday July 20, 2022 @01:58PM (#32169709)
I did write a guide to C that's currently in beta. If it's any good or not... Well, I'll leave that up to you. :)

I also really like K&R2 and Van der Linden.

https://beej.us/guide/bgc/

Re:Beej updated the classic Linux network programming guide by lprd on Wednesday July 20, 2022 @02:08PM (#32169836)
I'll most definitely be checking out your guide! Thank you so much for your contributions in the community :) Will the latest revision of your Networking Guide be available on print any time soon? I'd love to buy a copy.
Re:Beej updated the classic Linux network programming guide by jamal-kumar on Wednesday July 20, 2022 @05:32PM (#32172649)
Has anyone actually even tried the K&R book in the past couple of decades and not run into issues like the assumption of unbuffered shell output? You get like one or two chapters in and things are already behaving outside of how they did when that book was written in the 1980s. It's a classic, yes, but I don't recommend it to anyone outside of people writing code in C89 for vintage systems... Yet the amount of suggestions I see from people who haven't actually learned C from scratch since the 1990s to read that particular title is high enough that I can't do anything but scratch my head over it. Tons has changed over thirty plus years.

If you're looking for something up to date I'd recommend this:

https://gustedt.gitlabpages.inria.fr/modern-c/

Re:Beej updated the classic Linux network programming guide by icedchai on Wednesday July 20, 2022 @08:02PM (#32174094)
I taught myself C from K&R 2, and a platform-specific (Amiga!) book, back when I was a teenager. In three decades, not much has really changed with the core language.
Re:Beej updated the classic Linux network programming guide by jamal-kumar on Thursday July 21, 2022 @01:43AM (#32176161)
While the core language has stayed the same the tooling and development environment has changed quite a lot. Proper modern compiler flags (-Wall etc) for example would be a huge help to new learners and for best practices, but k&r isn't mentioning these. I still think it's a good book but if you throw it at someone new to this they're going to be wondering why what they are writing isn't behaving as expected.
Re:Beej updated the classic Linux network programming guide by emmelaich on Wednesday July 20, 2022 @06:53PM (#32173461)
K&R2 is hard to beat for size and clarity of writing.

Could you elaborate on the "unbuffered shell output" comment?

Re:Beej updated the classic Linux network programming guide by icedchai on Wednesday July 20, 2022 @08:02PM (#32174098)
I'm guessing he's talking about the putchar/getchar example in the first or second chapter?
Re:Beej updated the classic Linux network programming guide by jamal-kumar on Thursday July 21, 2022 @01:36AM (#32176115)
Yeah that. It's extremely confusing and where a ton of people stop reading it.
Re:Beej updated the classic Linux network programming guide by shric on Wednesday July 20, 2022 @05:08PM (#32172353)
I think C Programming: A Modern Approach by K.N. King is great.
Re:Beej updated the classic Linux network programming guide by jsd1982 on Wednesday July 20, 2022 @12:23PM (#32168060)
Not necessarily but it does help. These tutorials focus mainly on the Berkeley Sockets API which can be exposed as-is (or with slight modification) to many languages beyond just C/C++.
Re:Beej updated the classic Linux network programming guide by astrobe_ on Wednesday July 20, 2022 @12:43PM (#32168406)
It is useful mainly if you have to do some netprog in C, and secondarily if you have to deal with language bindings that do a 1:1 mapping to the BSD socket API.

In other words, you will know when you need it - unless you forget it exists (note: bookmarking it might be a good idea, cause you could remember something like this exists but "what was the name again?").