From owner-freebsd-hackers Wed Nov 13 10:04:31 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id KAA02406 for hackers-outgoing; Wed, 13 Nov 1996 10:04:31 -0800 (PST) Received: from brasil.moneng.mei.com (brasil.moneng.mei.com [151.186.109.160]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id KAA02396 for ; Wed, 13 Nov 1996 10:04:26 -0800 (PST) Received: (from jgreco@localhost) by brasil.moneng.mei.com (8.7.Beta.1/8.7.Beta.1) id MAA23482; Wed, 13 Nov 1996 12:03:22 -0600 From: Joe Greco Message-Id: <199611131803.MAA23482@brasil.moneng.mei.com> Subject: Re: Programming technique for non-forking servers? To: exidor@superior.net (Christopher Masto) Date: Wed, 13 Nov 1996 12:03:22 -0600 (CST) Cc: hackers@FreeBSD.ORG In-Reply-To: <199611131705.MAA10785@nimbus.superior.net> from "Christopher Masto" at Nov 13, 96 12:05:50 pm X-Mailer: ELM [version 2.4 PL24] Content-Type: text Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > This reminds me of a related thing that's been nagging me since I > first started writing Unix programs about 5 years ago. Occasionally > (more often recently) I'm working on something that screams for a > couple of cooperating processes.. coming from the Amiga world, this > seems very natural, and on the Amiga it was very simple. One process > opens up a "message port", and another process sends messages to it. > The closest thing I have seen is creating a socket in the Unix > domain.. but this doesn't seem very popular, so I get the feeling it > isn't often the right answer. As far as I can tell... you're wrong. :-) UNIX is fundamentally different from crud like DOS... interprocess communication is a core part of the system and is actively encouraged. Build your own tools from shell commands. Write your own C code that opens dozens of sockets. That should be relatively similar to the Amiga world, as I understand it, although I have never owned one. I think what puts off most relative newcomers is the complexity of the BSD socket paradigm. This is NOT intended to prevent or discourage you from using it! It is simply due to the incredible flexibility inherent in a network-aware interprocess communication layer. Where else can you whip out a dozen lines of C code that connects to a process in Japan and starts talking to it? If you find it somewhat more complex than you would prefer, write library functions to simplify the "grunt work". You will not be able to cover every scenario, but you can cover the common ones where you just want to open a connection to someplace. Even though I have been doing this stuff for a long time now, I still use a set of library routines I wrote a long time ago, because in 90% of the cases, I just want to do something simple. There are, of course, other forms of IPC available as well. IPC is _great_. It is _often_ the right answer. ... JG