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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a24:4105:: with SMTP id x5mr5067481ita.33.1549521687244; Wed, 06 Feb 2019 22:41:27 -0800 (PST) X-Received: by 2002:a9d:19a4:: with SMTP id k33mr12030otk.5.1549521687024; Wed, 06 Feb 2019 22:41:27 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.linkpendium.com!news.linkpendium.com!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!q69no100216itb.0!news-out.google.com!v71ni120ita.0!nntp.google.com!k10no100203itk.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 6 Feb 2019 22:41:26 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=191.17.174.180; posting-account=TRgI1QoAAABSsYi-ox3Pi6N-JEKKU0cu NNTP-Posting-Host: 191.17.174.180 References: <47f17695-f9a5-4024-b2da-3f13209dc4fd@googlegroups.com> <818f5ff4-f18d-42b8-950d-9b597c012aa4@googlegroups.com> <62406dfb-54c9-4db3-b461-0ad72d4a782c@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Ada x Datagram Sockets From: "Rego, P." Injection-Date: Thu, 07 Feb 2019 06:41:27 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:55452 Date: 2019-02-06T22:41:26-08:00 List-Id: On Thursday, February 7, 2019 at 4:00:11 AM UTC-2, Egil H H wrote: > > > On Wednesday, February 6, 2019 at 6:10:37 PM UTC-5, Rego, P. wrote: > >=20 > > Just the string "test". I also confirmed that the MQL container (uchar = data[]) has really the size 5. > >=20 >=20 > Right, Ada strings are not zero-terminated, and the size of the string ne= eds=20 > to come from somewhere, which is why String'Input will interpret the firs= t x bits (probably 32, but may depend on your platform) as the length. So i= n this > case, "test" becomes a big number and 'Input will most likely try to allo= cate > just under 2GB on your stack (and probably at least twice, in order to c= opy > the result into your string). A C++ uchar in Windows machine is usually 1 byte, so assuming that both use= the same signature, both messages (from C++ and from Ada) should be of sam= e size, right?=20 (I checked both send commands used by Ada sockets and MQL sockets, and they= both are using standard win32 signatures, I mean for C++ case int sendto( SOCKET s, const char *buf, int len, int flags, const sockaddr *to, int tolen ); and in Ada case a imported function function C_Sendto (S : C.int; Msg : System.Address; Len : C.int; Flags : C.int; To : System.Address; Tolen : C.int) return C.int; ) >=20 > Don't use Ada stream attributes to communicate with other languages. >=20 > And, as some will tell you, don't use them at all, especially for arrays,= as > each array element may end up being transferred as a single data packet, = destroying performance. This is quite controversial, in this case. I'd usually agree with you, howe= ver the use of Ada stream is not by choice. The whole GNAT Ada package uses= Ada streams, and actually the above code was entirely extracted from the c= omments from g-sockets.ads with minimum modification. I don't think it woul= d be wise to re-implement Ada Sockets pkg to be more efficient.