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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f69eb259f3ed2afb X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!feed.news.tiscali.de!blackbush.cw.net!cw.net!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail From: Michael Paus Newsgroups: comp.lang.ada Subject: Re: Using GNAT.Sockets Date: Sun, 17 Apr 2005 17:35:36 +0200 Organization: 1&1 Internet AG Message-ID: References: <1113404846.310840.322920@z14g2000cwz.googlegroups.com> <1113556017.302630.65980@l41g2000cwc.googlegroups.com> NNTP-Posting-Host: p50811022.dip0.t-ipconnect.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: online.de 1113752137 19569 80.129.16.34 (17 Apr 2005 15:35:37 GMT) X-Complaints-To: abuse@einsundeins.com NNTP-Posting-Date: Sun, 17 Apr 2005 15:35:37 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041217 X-Accept-Language: en-us, en In-Reply-To: X-Enigmail-Version: 0.90.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Xref: g2news1.google.com comp.lang.ada:10513 Date: 2005-04-17T17:35:36+02:00 List-Id: Bob Spooner wrote: > Well, it's not _quite_ that simple... > "Michael Paus" wrote in message > news:d3o9le$cgm$1@online.de... > >>markp wrote: >> >> >>>Bob, >>> >>>Thanks for your reply. My basic quesion is I realize that a socket read >>>will not necessarily return all the data requested. The Receive_Socket >>>item input parameter takes and array. Will a subsequent read place data >>>at the beginning of the array, meaning I have to copy data out before I >>>read again? >> >>Yes it does but you do not have to copy your data. Just have a look at >>Duncans example. He told you already how to do it. You just have to call >>this in a loop until Last = My_Buffer'Last. >> >> procedure Receive_Socket >> (Socket => My_Socket, >> Item => My_Buffer (Last + 1 .. My_Buffer'Last), >> Last => Last); >> >>The first byte will be stored at the first position of the buffer array >>you provide, but in the above example we specify a sub-range of the >>whole buffer and so the first element of this is at the index Last + 1 >>of the whole buffer and this is exactly what you need. >> >>Michael > > > Your buffer needs to be big enough to read the largest message you expect, > and for the shorter messages, you need to use a slice of the buffer equal to > the size of the message being read so that you don't read in some of the > following message along with the current message. Yes, of course the assumption in the above example is that your intention is to finally read exactly My_Buffer'Length bytes. Michael