From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,62ab88cac7a1dbb X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.84.168 with SMTP id a8mr1202168paz.25.1348259449843; Fri, 21 Sep 2012 13:30:49 -0700 (PDT) Path: a8ni6165122pbd.1!nntp.google.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!news.mi.ras.ru!goblin-spool!goblin3!goblin.stu.neva.ru!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Gnat Sockets & Streams Date: Sat, 15 Sep 2012 20:17:30 +0200 Organization: cbb software GmbH Message-ID: <1ttqhbx9n4s95.16m595tl7m69p$.dlg@40tude.net> References: <201209142101005065-rblove@airmailnet> <6owmaht6knzo.brd5acsbbu7j$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: 9A8bJrx4NhDLcSmbrb6AdA.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-09-15T20:17:30+02:00 List-Id: On Sat, 15 Sep 2012 18:02:34 +0100, Simon Wright wrote: > "Dmitry A. Kazakov" writes: > > (from bitter experience communicating with many different device > types/protocols) > >> Using streams and sockets you should remember: >> >> 1. Stream attributes are not portable. The only type you should read/write >> into the socket stream is Unsigned_8 or equivalent (octet). > > But you are not likely to have much trouble if you use the same > compiler, and ideally the same version, on either side. Yes, but why gamble? >> 2. As with any I/O you should honestly implement all layers of the protocol >> at hand. Don't try shortcuts like stream type attributes, representation >> clauses etc. > > The stream type attributes may well be OK, and (as above) if you have > the same compiler either end you will probably be OK. It's quite another > matter if your Ada has to talk to someone else's C. I argue that this is not solid engineering. Even if two Ada programs are to communicate, the protocol must be fully specified first. The implementations must conform that specification. If a stream attribute indeed implements the specification, fine, the code should document that and explain why. What I am strongly against is that sort of upside-down design, when people implement something first and then declare that the would-be protocol is what the stuff accidentally happens to do. >> 3. Network protocols are packet-oriented. You have to use Write (of the >> type Root_Stream_Type) instead of attributes to ensure that the packet is >> sent as a whole. It matters for both UDP and TCP/IP. > > This is SO TRUE for UDP. I've never used multicast but anywhere there > are datagrams you need to heed this! > > The approach we adopted was to use a memory stream (eg [1]) and then use > Write on the resulting Stream_Element_Array. > > Not sure why it would matter for TCP? (unless you've used TCP_NO_DELAY, > of course). Yes, mainly to have it NO_DELAY-agnostic. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de