From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA06339 for caml-redistribution@pauillac.inria.fr; Sat, 18 Mar 2000 18:57:02 +0100 (MET) Resent-Message-Id: <200003181757.SAA06339@pauillac.inria.fr> Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA19216 for ; Sat, 18 Mar 2000 10:15:02 +0100 (MET) Received: from suburbia.net (suburbia.net [203.4.184.1]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id KAA17435 for ; Sat, 18 Mar 2000 10:15:00 +0100 (MET) Received: by suburbia.net (Postfix, from userid 110) id 2FBE86C504; Sat, 18 Mar 2000 20:14:56 +1100 (EST) Sender: proff@suburbia.net To: caml-list@inria.fr Subject: multi-threaded udp resolver Cc: proff@iq.org From: Julian Assange Date: 10 Mar 2000 09:34:47 +1100 Message-ID: Content-Type: text/plain; charset=us-ascii User-Agent: Gnus/5.0802 (Gnus v5.8.2) XEmacs/21.1 (Big Bend) MIME-Version: 1.0 Resent-From: weis@pauillac.inria.fr Resent-Date: Sat, 18 Mar 2000 18:57:02 +0100 Resent-To: caml-redistribution@pauillac.inria.fr I've previously written a multi-threaded udp dns resolver in c (not threads so much as a fsm emulating threads). I'd like to, if possible write one in ocaml directly, rather than simply hooking into the C code (which wouldn't be that simple anyway, due to the various timers, management of fd's etc it needs). While ocaml provides appropriate udp send/receive functions, the best mechanism for understanding the structure of dns packets is unknown to me. DNS packets are `loosely' structured. That is, there are many different structural elements (including arrays of those elements), and exactly how they are crammed into a packet can only be determined by reading the structure. i.e the first part of the structure describes the type (but not structure) of the next strucural element and so on. Vixie's named/bind daemon doesn't even attempt to describe the structure in any sort of data form, but rather uses the code flow itself to describe the structure (e.g pulling 16 bits, assigning it to a variable, advancing the interpretation pointer by 16 bits, testing the variable, pulling 32 bits etc). This method is incredibly error-prone, and it's hard to see a good way of fitting it in with ocaml's type system. Any ideas on the best way to approach this problem? Cheers, Julian. -- Stefan Kahrs in [Kah96] discusses the notion of completeness--programs which never go wrong can be type-checked--which complements Milner's notion of soundness--type-checked programs never go wrong [Mil78].