From owner-freebsd-hackers Sat Feb 22 10:20:32 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id KAA00528 for hackers-outgoing; Sat, 22 Feb 1997 10:20:32 -0800 (PST) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.50]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id KAA00516 for ; Sat, 22 Feb 1997 10:20:28 -0800 (PST) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id LAA04898; Sat, 22 Feb 1997 11:19:14 -0700 From: Terry Lambert Message-Id: <199702221819.LAA04898@phaeton.artisoft.com> Subject: Re: Alternatives to SYSV IPC? To: joerg_wunsch@uriah.heep.sax.de Date: Sat, 22 Feb 1997 11:19:14 -0700 (MST) Cc: hackers@freebsd.org In-Reply-To: from "J Wunsch" at Feb 22, 97 12:29:27 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > ..., but what about messages? Sockets could be used, but they just > > provide an arbitrary stream of bytes, not discrete messages. FIFOs > > have the same problem, and pollute the filename space (I have the > > same problem with using mmap() for shared memory). > > What else than `an arbitrary stream of bytes' is a message? A *framed* stream of bytes. A reliable datagram of a given size. > Define > your message to be a structure, with a length and type field at the > beginning, and type-dependant data following. This frames the byte stream on send. Because of the recv() does not block for the full requested amount, it will *not* frame the receive. The length field would not be necessary if the framing were enforced by the transport: a receive into a buffer larger than the maximum allowable message type that could be framed for any given transmitter state would be sufficient. You do a recv into the buffer, then you dispatch based on a field dereference from the newly acquired data (probably a type field), and dispatch the data for processing from a big switch statement. No additional recv's necessary. Twiddling around SO_RCVLOWAT and SO_RCVTIMEO would only work if all your datagrams were identically sized. Regards, Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.