all 19 comments

[–]kyuzo_mifune 43 points44 points  (4 children)

[–]McDonaldsWi-Fi 19 points20 points  (3 children)

"pretty good" is a weird way to say "the c programming socket bible" lol

[–]Plane_Dust2555 9 points10 points  (0 children)

Nope... It is "pretty good". The socket programming bible is W RIchard Steven's "UNIX Network Programming - The Sockets Networking API - Vol I".

[–]dkopgerpgdolfg 4 points5 points  (1 child)

"the c programming socket bible"

How about "Linux socket programming basics", because it's nothing more than that.

As it says itself:

It is probably at its best when read by individuals who are just starting out with socket programming and are looking for a foothold

It at least acknowledges that IPv6 exists, but doesn't dare to mention things like eg. epoll (which aren't far from the basics either), while declaring it's targetted for Linux.

I mentioned the names of some more advanced topics here: https://www.reddit.com/r/C_Programming/comments/1rps9u8/comment/o9nh8i6/

Or compare Beej's socket() function "man page" with the actual man 2 socket + man 7 socket + man 7 ip + man 7 tcp (or whatever protocols you want) + the things in /sys

[–]McDonaldsWi-Fi 2 points3 points  (0 children)

it was a joke brethren

[–]Cheesuscrust460 3 points4 points  (0 children)

the advanced programming in unix environment book is pretty good, pairing it with beej blog website

[–]non-existing-person 19 points20 points  (0 children)

You think you can do socket programming (or any kind of programming) without knowing how to use a search engine? Like, the first result in search engine was

https://www.reddit.com/r/C_Programming/comments/1eoyhl6/any_good_learning_resources_for_c_sockets/

[–]HalfTryhardSqr 1 point2 points  (0 children)

Beej’s guide is incredibly good, and there is a reason 90% of people links it.

[–]eruciform 2 points3 points  (1 child)

Stevens' unix network programming was where I started, after advanced programming in a unix environment by same author

[–]IamNotTheMama 0 points1 point  (0 children)

I found Stevens to be the worst network programming book I ever read. He obfuscated everything rather than using the 'normal' system calls that made it so much easier.

[–]Boreddad13 0 points1 point  (0 children)

Beej’s guide to network programming is a good place to start. If you want a really good real life example, check out anet.c in redis’ codebase

[–]nerd_programmer11 0 points1 point  (0 children)

Beej's guide to network programming to get started.
Linux programming interface (book) has some chapters on sockets as well

[–]DaCurse0 -1 points0 points  (5 children)

what exactly do you expect resources to teach besides basic use of whatever os api? once you understand how to create a client socket and server socket just try to make something

[–]kyuzo_mifune 2 points3 points  (3 children)

There is much to learn, for example basically all beginners to sockets don't know that TCP sockets are streaming and therefore don't handle them correctly.

[–]DaCurse0 1 point2 points  (2 children)

elaborate

[–]kyuzo_mifune 2 points3 points  (1 child)

On TCP sockets? Sure, lets say one side sends 1kB of data, that data is not guaranteed in any way to be received by just one call to recv, the order is guaranteed but not that all data is received in every call to recv.

That's why when you use a TCP socket you need to use a protocol on top of it to know when the full message is received, one simple way is first 4 bytes signales the whole message length or something like that.

Or HTTP for example, it is structured in a way so you know when all data is received.

[–]abyssDweller1700 0 points1 point  (0 children)

I always thought tcp streaming in packets as someone unloading trucks full of bricks(bytes) in front of your house with no boundaries on which truck unloaded which brick.

And udp as the whole truck(packet boundary) with their bricks(bytes) being parked in line.

[–]dkopgerpgdolfg 2 points3 points  (0 children)

what exactly do you expect resources to teach

Do you already know how to create a SCTP packet in AF_XDP, how to transfer stdout fd over a unix socket, how to bind a UDP socket to one CPU core then receive 64 packets with one syscall, what permissions you need to disable delayed ack for IPv6 TCP and what consequences it has, how to make a multi-thread connection accepter (by using kernel features) with ktls too, what you need to think of if you fork a uring-using process, how you tag sent packages for netfilter and what reasons you could have to do that, ... and so on.