In my opinion, Linux network programming, especially socket programming, isn’t that difficult. However, learning this topic on your own can be challenging because many online resources are unclear, and sample codes often only cover the basics. You might find yourself unsure of what to do next. That's why I created this tutorial. It aims to give you clear guidelines and plenty of examples to help you understand better.
Since I didn’t see this in the list of references, I have to ask — have you heard of the (famous) Beej’s Guide to Network Programming [1]? It’s a classic (in the sense that it’s been around for a long, long time and goes into many more details) on this topic.
beej was also a great place to take the first steps in network programming :) I just updated my reference list. This is one of my missing piece. Thank you for the reminder.
Actually is extremely simple. I learned by looking the original papers[0]
As you say, just lots of bad examples online. The only thing that made me a little bit crazy at the beginning, was the fact that TCP is a stream without delimiters, no packet concept. Other than that, is not more difficult than writing and reading a file.
Thank you for referring to a BSD document. Most people have no idea that the modern reference network stack implementation comes from BSD and not Linux.
The guide looks well written and I can't see any major errors (just skimmed it.) But some of the diagrams are potentially misleading. E.g.
read <---- write
write ----> read
Implies that send/recv perfectly correlate to each other when they can be split up in stream sockets. Your code addresses that already with loops. So I know you know that. Just confusing diagrams I guess.
very nicely done! smallest nitpick in the world but "comprehensive" and "linux" kinda sorta implies I could read at least a blurb about epoll and io_uwrong or whatever its called lol
I don't know of one. However, Python's socket API is mostly a thin wrapper around the C socket API. Assuming you know Python, it should be easy enough to learn from a tutorial like this one without a Python-specific guide. Note the matching function and constant names:
In my opinion, Linux network programming, especially socket programming, isn’t that difficult. However, learning this topic on your own can be challenging because many online resources are unclear, and sample codes often only cover the basics. You might find yourself unsure of what to do next. That's why I created this tutorial. It aims to give you clear guidelines and plenty of examples to help you understand better.
I skimmed through it and it looks good.
Since I didn’t see this in the list of references, I have to ask — have you heard of the (famous) Beej’s Guide to Network Programming [1]? It’s a classic (in the sense that it’s been around for a long, long time and goes into many more details) on this topic.
[1]: https://beej.us/guide/bgnet/
Beej’s was great for me when I was doing some socket programming in C for my OS class in grad school. Classic and invaluable resource.
Was just skimming the comments for a mention of Beej's guide, was about to post almost the same comment.
What an amazing resource.
I feel like the last time I looked at it, it has been updated too so was pretty current.
Also agree the OP looks like a good guide.
beej was also a great place to take the first steps in network programming :) I just updated my reference list. This is one of my missing piece. Thank you for the reminder.
Actually is extremely simple. I learned by looking the original papers[0]
As you say, just lots of bad examples online. The only thing that made me a little bit crazy at the beginning, was the fact that TCP is a stream without delimiters, no packet concept. Other than that, is not more difficult than writing and reading a file.
[0] https://docs-archive.freebsd.org/44doc/psd/20.ipctut/paper.p...
Another useful resource: https://beej.us/guide/bgnet/
Edit: beej seems already cited and beloved
Thank you for referring to a BSD document. Most people have no idea that the modern reference network stack implementation comes from BSD and not Linux.
I just browsed through. Content looks concise to me. Might want to add syntax highlighting to the code to make it more visible.
The guide looks well written and I can't see any major errors (just skimmed it.) But some of the diagrams are potentially misleading. E.g.
read <---- write
write ----> read
Implies that send/recv perfectly correlate to each other when they can be split up in stream sockets. Your code addresses that already with loops. So I know you know that. Just confusing diagrams I guess.
very nicely done! smallest nitpick in the world but "comprehensive" and "linux" kinda sorta implies I could read at least a blurb about epoll and io_uwrong or whatever its called lol
Is there a guide about Linux Cgroups programming?
Does anyone know - Is there a guide like this that does this with Python instead of the C Socket API?
I don't know of one. However, Python's socket API is mostly a thin wrapper around the C socket API. Assuming you know Python, it should be easy enough to learn from a tutorial like this one without a Python-specific guide. Note the matching function and constant names:
https://docs.python.org/dev/library/socket.html#socket.socke...
The official Python documentation actually comes with a Socket Programming HOWTO that goes over conceptual topics and intended socket API usage:
https://docs.python.org/dev/howto/sockets.html#socket-howto
It gets overlooked because most folks only check the Tutorial and the Standard Library sections.
How about this? https://realpython.com/python-sockets/
Seems to cover all the basics...
Typically,
1) you just understand the workflow of your socket server and client
2) you then decide between TCP and UDP - and even if you want to work at higher layers like http or rpc - for the application you want to code
3) start coding with the boiler plate code for something like echo server and client.
https://mathspp.com/blog/sockets-for-dummies might help