6 ms·
Beej's Guide to Unix IPC (2010)
- pizza 11y agoAlso check out his guide to C programming [0] and his guide to network programming [1] [0] http://beej.us/guide/bgc/ http://beej.us/guide/bgc/ [1] http://beej.us/guide/bgnet/ http://beej.us/guide/bgnet/
- rubiquity 11y agoI owe my career to Beej. I was getting burnt out of web development and his guides (along with Jesse Storimer's books) made programming fun for me again. I highly recommend learning how Unix systems work. It's a lot of fun and opens up a whole new world of programming!
- shabbyrobe 11y agoI'm feeling the same way about web, I'd like to transition to something similar. I quite enjoy programming in C, so hopefully that helps. What are you doing at your job now? How did you go about making the switch from web to systems? Has it paid off with an increase in enjoyment?
- rubiquity 11y agoTruth be told, a significant portion of my day job is still web application stuff. The web, whether that's HTML/CSS/JS applications or APIs, is inescapable at this point for a huge portion of programmers. Only the lucky few get to hack on databases, hypervisors and file systems for a living! But, armed with the knowledge of sockets, processes, etc. and how this correlates to performance/scaling, I've been able to carve out roles where I get to spend a decent amount of time working on problems that I get excited about. But even before I was able to work the knowledge into my day job, nothing beats the dopamine rush of learning things that fascinate you! The rabbit holes that learning the basics of Unix have opened feel like they could occupy my hobbyist hours for the rest of my life.
- vivekian2 11y agoIts amazing how we think the grass is greener. I have been doing systems programming for the past 7 years and have been thinking about moving over to JS based web development for the past few months.
- kanungoparth 11y agoActually both of you are right. You need a break from what you have been doing from a long time. Perhaps exchanging your jobs with one another might help. :)
- rubiquity 11y agoAgreed. I think we humans just need change every now and then. Even when the problems and tools we use to solve those problems never change, we still somehow get upset with the tools or the problems.
- ridiculous_fish 11y agoSomething I've struggled to implement on Linux is cross-process multicast notifications, where any process can post and multiple subscribed processes receive it. FIFOs and SysV IPC are unicast, and I think DBus is too. On OS X there's notify(3) which is very nice. Any good options on Linux, other than writing my own socket server?
- troglobit 11y agoTIPC is pretty neat, it's available in the kernel since quite a long time (AF_TIPC) and works between processes on one or many nodes. http://tipc.sourceforge.net/ http://tipc.sourceforge.net/
- pdkl95 11y agoThe solution for this kind of problem will depend heavily on what type of messages you're trying to send. When messaging becomes that complex, there are often other things that impact the overall design in important ways that need need to be considered. For example, if I was implementing something that is usually associated with user events (rare-ish, basically zero bandwidth, complex signal with stateful messaging semantics), I would probably just write a simple server to manage it all. This has an advantage of centralizing any messaging complexity and lets you manage any multi-message state easily. Rebroadcasting messages to allow peer-to-peer messaging would be a trivial addition. This would probably UNIX sockets if the connections are persistent (which can changed into AF_INET{,6} sockets easily, if you wanted to add network support). For something that requires very low latency (e.g. audio/MIDI), in the past I have had to use shared memory, which has zero overhead once it is setup (no syscalls or context switches). Here, the need for low latency dictated the design. Of course, this means managing locks. Not fun, but a cost that is sometimes worth paying. There really isn't a one-size-fits all solution. edit: Or, as troglobit said, TIPC. I keep forgetting that we now have it has an option. :(
- ridiculous_fish 11y agoThanks for the reply. My use case is very simple: a stateless "something happened" notification, which can be delivered asynchronously. Coalescing or even occasional drops are fine. I did originally use a Unix domain socket server, but that added a lot of complexity: one has to arrange for it to be launched, guard against the possibility that it gets stuck, version it, deal with permissions, etc. My new solution on Linux is a total hack: there's a FIFO, and to post a notification, you write to it. Clients see that the FIFO became readable, and that change represents the notification. The sender then drains the data it wrote, so that the FIFO becomes unreadable again. This is a total abuse of FIFOs, but it's proven to be much simpler than trying to manage a separate server. I've never heard of TIPC. From a little searching it looks like it's very capable but geared towards clusters, and is overkill for my use case. What do you think?
- ladybro 11y agoBeej helped me pass my Operating Systems final last semester. Really quality and entertaining guides he puts together.
- alekratz 11y agoBeej is great. I've printed this book out and have it sitting in a binder on my bookshelf.
- jrapdx3 11y agoI'll add to the chorus of praise for Beej's work. I've often consulted this particular guide and the companion piece for networks as well. Helped me write web and other servers, a great way to learn about important technologies, providing knowledge that stays useful even if the production server runs on Node.js. Besides, I'm biased. "BJ" happens to be my wife's unofficial name. She's a remarkably smart person, so I was predisposed to think "BeeJ" would know what he's talking about and it turns out he did.
- paraiuspau 11y agoAhh.... summer 98, discovering sockets, too poor to afford Stevens, 14.4 kbps modem, netscape 4.x rendering Beej's .edu site (forgotten now), me staring my future in the face. Thank you for your efforts, Brian!
- am185 11y agobeej! how can i forget the his network programming guide!
- stuaxo 11y agoThanks for reminding me, I really need to put this into practice, so much great stuff in here.
- ausjke 11y agowhat about an update to posix IPC instead of sysV? I thought Posix IPC is "better" these days?