comp.lang.ada
 help / color / mirror / Atom feed
From: "Rego, P." <pvrego@gmail.com>
Subject: Re: Ada x <whatever> Datagram Sockets
Date: Fri, 8 Feb 2019 12:00:53 -0800 (PST)
Date: 2019-02-08T12:00:53-08:00	[thread overview]
Message-ID: <da2d28cc-29f4-4e94-ab2b-5b81e4f1b0af@googlegroups.com> (raw)
In-Reply-To: <519fd5e0-eb4e-432e-85cc-d7a37510c957@googlegroups.com>

> For giggles try modifying your receive code a bit:
> 
>       declare
>          subtype Test_String is String(1..5);
>          Message : Test_String := Test_String'Input (Channel);
>       begin
>          Address := SOCKETS.Get_Address (Channel);
>          Text_IO.Put_Line (Message & " from " & SOCKETS.Image (Address));
>          Test_String'Output (Channel, Message);
>       end; 

The exception continues to come, but now the catcher comes from 
>          Message : Test_String := 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
> 
>       subtype Test_String is String(1..4);
> 
> 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 not 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 long 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.  

Well... specifically GNAT.Sockets, from g-socket.ads I couldn't find any Receive_Sockets -like signature using any data container different than streams. 


> 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.  

This will be the next step :-) 

  parent reply	other threads:[~2019-02-08 20:00 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-06 23:10 Ada x <whatever> Datagram Sockets Rego, P.
2019-02-07  0:42 ` Jere
2019-02-07  5:28   ` Rego, P.
2019-02-07  6:00     ` Egil H H
2019-02-07  6:41       ` Rego, P.
2019-02-07  7:23         ` Egil H H
2019-02-07 11:48           ` Jere
2019-02-08 19:41           ` Rego, P.
2019-02-08 20:31             ` Dmitry A. Kazakov
2019-02-08 21:56               ` Rego, P.
2019-02-07  8:28         ` Dmitry A. Kazakov
2019-02-07 10:08           ` Simon Wright
2019-02-08  0:15           ` Randy Brukardt
2019-02-08  8:25             ` Simon Wright
2019-02-08 13:24               ` Dmitry A. Kazakov
2019-02-09  1:01               ` Randy Brukardt
2019-02-10 17:54                 ` Simon Wright
2019-02-11  8:39                   ` Dmitry A. Kazakov
2019-02-11 13:35                     ` Simon Wright
2019-02-11 14:25                       ` Dmitry A. Kazakov
2019-02-11 15:19                         ` Simon Wright
2019-02-11 16:04                           ` Dmitry A. Kazakov
2019-02-11 23:19                   ` Randy Brukardt
2019-02-12 11:35                     ` Simon Wright
2019-02-08 19:44           ` Rego, P.
2019-02-07 11:47         ` Jere
2019-02-07 18:00           ` Jeffrey R. Carter
2019-02-08 20:35             ` Rego, P.
2019-02-08 21:26               ` Jeffrey R. Carter
2019-02-08 22:02                 ` Rego, P.
2019-02-08 21:38               ` Dmitry A. Kazakov
2019-02-08 20:00           ` Rego, P. [this message]
2019-02-07 10:11     ` Simon Wright
2019-02-08 20:03       ` Rego, P.
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox