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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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.180.94.98 with SMTP id db2mr98503wib.2.1348190011292; Thu, 20 Sep 2012 18:13:31 -0700 (PDT) Path: ed8ni3498083wib.0!nntp.google.com!feeder2.cambriumusenet.nl!feeder1.cambriumusenet.nl!feed.tweaknews.nl!85.12.40.130.MISMATCH!xlned.com!feeder1.xlned.com!border2.nntp.ams.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsreader4.netcologne.de!news.netcologne.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Gnat Sockets & Streams Date: Sat, 15 Sep 2012 18:02:34 +0100 Organization: A noiseless patient Spider Message-ID: References: <201209142101005065-rblove@airmailnet> <6owmaht6knzo.brd5acsbbu7j$.dlg@40tude.net> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="a9272c9c584810f74e3f95ce46cbeceb"; logging-data="32191"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hU9Dt2zs5LpvbTXhfHRUR8CS+uMtTsvc=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (darwin) Cancel-Lock: sha1:CuRnrpsB4mkmEOeInsTcAIULPY8= sha1:fc/HeDjJC23Y9KgsFOzI87ws+BA= Content-Type: text/plain Date: 2012-09-15T18:02:34+01:00 List-Id: "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. > 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. > 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). [1] http://booch95.svn.sourceforge.net/viewvc/booch95/trunk/src/bc-support-memory_streams.ads?revision=1420&view=markup