From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 730307EEEF for ; Fri, 12 Jun 2015 10:55:26 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of romain.bardou@inria.fr) identity=pra; client-ip=87.98.150.177; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="romain.bardou@inria.fr"; x-sender="romain.bardou@inria.fr"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of romain.bardou@inria.fr) identity=mailfrom; client-ip=87.98.150.177; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="romain.bardou@inria.fr"; x-sender="romain.bardou@inria.fr"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@15.mo3.mail-out.ovh.net) identity=helo; client-ip=87.98.150.177; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="romain.bardou@inria.fr"; x-sender="postmaster@15.mo3.mail-out.ovh.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DtAgAXnnpVnLGWYldcDgiDTl+/T4V6AoFFTAEBAQEBARIBAQEBAQYNCQkhLkEFg10BAQQ4OwUBEAsYCRYPCQMCAQIBRQYNAQcCiC8BCNVTAQEBAQEBBAEBAQEBHYoggSOFBgeELQEEmBuGcYEwQItbhlyDW4IsH4EUQG6CRgEBAQ X-IPAS-Result: A0DtAgAXnnpVnLGWYldcDgiDTl+/T4V6AoFFTAEBAQEBARIBAQEBAQYNCQkhLkEFg10BAQQ4OwUBEAsYCRYPCQMCAQIBRQYNAQcCiC8BCNVTAQEBAQEBBAEBAQEBHYoggSOFBgeELQEEmBuGcYEwQItbhlyDW4IsH4EUQG6CRgEBAQ X-IronPort-AV: E=Sophos;i="5.13,601,1427752800"; d="scan'208";a="164768747" Received: from 15.mo3.mail-out.ovh.net ([87.98.150.177]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 12 Jun 2015 10:55:26 +0200 Received: from mail136.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo3.mail-out.ovh.net (Postfix) with SMTP id 6F344FFCD12 for ; Fri, 12 Jun 2015 10:55:25 +0200 (CEST) Received: from localhost (HELO queueout) (127.0.0.1) by localhost with SMTP; 12 Jun 2015 10:55:25 +0200 Received: from amontsouris-652-1-179-131.w90-24.abo.wanadoo.fr (HELO ?192.168.1.15?) (romain@bardou.fr@90.24.146.131) by ns0.ovh.net with SMTP; 12 Jun 2015 10:55:23 +0200 Message-ID: <557A9E7A.3010609@inria.fr> Date: Fri, 12 Jun 2015 10:55:22 +0200 From: Romain Bardou User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: Kenichi Asai CC: caml-list@inria.fr References: <20150612052738.GA3684@pllab.is.ocha.ac.jp> <557A8CBB.5050306@inria.fr> <20150612082626.GA5884@pllab.is.ocha.ac.jp> In-Reply-To: <20150612082626.GA5884@pllab.is.ocha.ac.jp> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Ovh-Tracer-Id: 11419721280443615776 X-Ovh-Remote: 90.24.146.131 (amontsouris-652-1-179-131.w90-24.abo.wanadoo.fr) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeekuddrjeduucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-Validation-by: romain@bardou.fr Subject: Re: [Caml-list] Marshall.from_channel and segmentation fault If the game is simple and values can easily be seen as sequences of char / bytes, 32-bit integers and fixed-length strings, your students could code their own serialization functions using the following functions from the Pervasives module: - output_char / input_char - output_byte / input_byte - output_binary_int / input_binary_int - output_string / really_input_string Serialization is an important part of network applications, so it may be an interesting skill for your students to learn. If on the other hand you feel that it would make it too complicated, there are several libraries which allow some form of serialization. I'm actually not that familiar with them as I tend to write serialization functions myself, but you may take a look at bin_prot, sexplib, biniou, yojson, piqi... Some of them use human-readable protocols such as JSON or s-expressions. They will be easier for your students to debug, but they are less efficient, which may be an issue for a game. Some of them have syntax extensions to generate the serialization functions from the source code of the type you want to serialize. Those will be the easiest to use. But I believe they tend to confuse students a lot, as the language is no longer pure OCaml and the build system needs to become aware of the syntax extension. Cheers, -- Romain Bardou On 12/06/2015 10:26, Kenichi Asai wrote: > Dear Romain, > > Thanks for the explanation. It seems you are suggesting that I should > use something else that performs runtime type checking rather than the > Marshall module. Is there some standard module I can use? > > I want to send various data along the Unix socket to create > interactive games using the Universe library for OCaml: > > http://pllab.is.ocha.ac.jp/~asai/Universe/ > > Because the library is used by beginning students, I want to avoid > segmentation fault without any useful error messages when they > mistakenly use the sent data as having different types. > > Sincerely, >