comp.lang.ada
 help / color / mirror / Atom feed
From: Andrew Shvets <andrew.shvets@gmail.com>
Subject: Finding the end of a stream from a socket
Date: Fri, 20 Oct 2017 19:05:01 -0700 (PDT)
Date: 2017-10-20T19:05:01-07:00	[thread overview]
Message-ID: <617c11a3-e092-4192-b769-4debef6ed6bf@googlegroups.com> (raw)

Hello,

I've been recently trying to make a small TCP server (a toy.)  I have a channel that reads Characters and was trying to find the end of the stream.  Reading the documentation, I came across the following in g-socket.ads:


type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class; 
--  Same interface as Ada.Streams.Stream_IO


I was trying to have a way to find out when the last Character was read from the stream.  I could catch the Ada.IO_Exceptions.End_Error exception, but I'm wondering if there is a better way.


Channel       : GNAT.Sockets.Stream_Access;

....

while not Ada.Streams.Stream_IO.End_Of_File(Channel) loop
  Character'Read(Channel, Received_Char);
  Ada.Text_IO.Put(Received_Char);
end loop;





Many thank yous in advance for your help!


             reply	other threads:[~2017-10-21  2:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-21  2:05 Andrew Shvets [this message]
2017-10-21  8:44 ` Finding the end of a stream from a socket Dmitry A. Kazakov
2017-10-21 13:45   ` Andrew Shvets
2017-10-21 18:11     ` Dennis Lee Bieber
2017-10-21 19:19       ` Dmitry A. Kazakov
2017-10-21 19:46         ` Andrew Shvets
2017-10-22 12:26         ` Andrew Shvets
2017-10-22 12:28           ` Andrew Shvets
2017-10-22 13:28           ` Dmitry A. Kazakov
2017-10-21 17:34   ` Andrew Shvets
2017-10-21 19:18     ` Andrew Shvets
replies disabled

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