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!news3.google.com!news.glorb.com!news.aset.psu.edu!not-for-mail From: "Bob Spooner" Newsgroups: comp.lang.ada Subject: Re: Using GNAT.Sockets Date: Fri, 15 Apr 2005 10:07:17 -0400 Organization: Penn State University, Center for Academic Computing Message-ID: References: <1113404846.310840.322920@z14g2000cwz.googlegroups.com> <1113556017.302630.65980@l41g2000cwc.googlegroups.com> NNTP-Posting-Host: nat1.arl.psu.edu X-Trace: f04n12.cac.psu.edu 1113574041 14712 128.118.40.76 (15 Apr 2005 14:07:21 GMT) X-Complaints-To: usenet@f04n12.cac.psu.edu NNTP-Posting-Date: Fri, 15 Apr 2005 14:07:21 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Xref: g2news1.google.com comp.lang.ada:10498 Date: 2005-04-15T10:07:17-04:00 List-Id: 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. Bob