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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Ada x Datagram Sockets Date: Thu, 07 Feb 2019 10:08:48 +0000 Organization: A noiseless patient Spider Message-ID: References: <47f17695-f9a5-4024-b2da-3f13209dc4fd@googlegroups.com> <818f5ff4-f18d-42b8-950d-9b597c012aa4@googlegroups.com> <62406dfb-54c9-4db3-b461-0ad72d4a782c@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="44368923b22a16a04c0cd1e66bdeae91"; logging-data="18992"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+R0KAGO2oz7hQn7ANVTL96ALynSIkH4nk=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (darwin) Cancel-Lock: sha1:bdeJj91fk5KAN4No0oRBWVVhH1s= sha1:DfJaBk/vhbp8Yt8hDVPKEXkn2Ec= Xref: reader01.eternal-september.org comp.lang.ada:55456 Date: 2019-02-07T10:08:48+00:00 List-Id: "Dmitry A. Kazakov" writes: > Well, using streams directly with UDP is calling for trouble (and > highly non-portable too). You should probably never use streams with > TCP either. Certainly not if socket options like NO_DELAY are > planned. The reason for this is to be found in ARM 13.13.2(9)[1] for 'Write: For composite types, the Write or Read attribute for each component is called in canonical order which will result in multiple calls to the underlying OS services; bad for TCP_NODELAY, very very bad for UDP. See GCC PR9535[2]. Note, the change applied really doesn't address the problem at all, in spite of being essentially my patch! I lost interest, having already decided to do as Dmitry says ... > Anyway, the way to do it is to have an outgoing packet buffer of > Stream_Element_Array. You put data there and then send all buffer to > the socket (write to the file etc), in one piece. > > If you want to use streams. Put a memory-mapped stream on top of the > Stream_Element_Array. Write packet whole. Flush the buffer contents to > the socket/file. ... see, in particular, comments 2, 6 in [2]. [1] http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-13-13-2.html#p9 [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=9535