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:24e:: with SMTP id 75mr250225itu.0.1549656054044; Fri, 08 Feb 2019 12:00:54 -0800 (PST) X-Received: by 2002:a9d:3476:: with SMTP id v109mr4306otb.7.1549656053603; Fri, 08 Feb 2019 12:00:53 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!goblin1!goblin.stu.neva.ru!k10no320952itk.0!news-out.google.com!9ni189itl.0!nntp.google.com!k10no320947itk.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 8 Feb 2019 12:00:53 -0800 (PST) In-Reply-To: <519fd5e0-eb4e-432e-85cc-d7a37510c957@googlegroups.com> 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> <519fd5e0-eb4e-432e-85cc-d7a37510c957@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Ada x Datagram Sockets From: "Rego, P." Injection-Date: Fri, 08 Feb 2019 20:00:53 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:55468 Date: 2019-02-08T12:00:53-08:00 List-Id: > For giggles try modifying your receive code a bit: >=20 > declare > subtype Test_String is String(1..5); > Message : Test_String :=3D Test_String'Input (Channel); > begin > Address :=3D SOCKETS.Get_Address (Channel); > Text_IO.Put_Line (Message & " from " & SOCKETS.Image (Address)); > Test_String'Output (Channel, Message); > end;=20 The exception continues to come, but now the catcher comes from=20 > Message : Test_String :=3D Test_String'Input (Channel); line. > I don't recall if C actually sends the '\0' at the end or not > for sockets, so if it doesn't, then change the Test_String declaration > to >=20 > subtype Test_String is String(1..4); >=20 > However, I think it does send the '\0', so you will also have to > handle that in your Ada code (since strings don't terminate with a > '\0' in Ada). It does not seem to be an '\0' problem, since the reception container is no= t limited (so, I don't mind receiving a 5 lenght message instead of 4), and= the message (should be) is too small. The real messages will not be so lon= g as well, in the real case it should have the same issue. > I've never used streams with the GNAT socket package for production code, > so I cannot comment on them, but the package definitely offers other > options besides streams. =20 Well... specifically GNAT.Sockets, from g-socket.ads I couldn't find any Re= ceive_Sockets -like signature using any data container different than strea= ms.=20 > I generally have a task that periodically > reads up to a specific number of bytes into a buffer and then my other > tasks can handle the data as they see fit. =20 This will be the next step :-)=20