comp.lang.ada
 help / color / mirror / Atom feed
From: Michael Paus <pausnospam@nospamib-paus.com>
Subject: Re: Using GNAT.Sockets
Date: Sun, 17 Apr 2005 17:35:36 +0200
Date: 2005-04-17T17:35:36+02:00	[thread overview]
Message-ID: <d3tvo9$j3h$1@online.de> (raw)
In-Reply-To: <d3ohqp$ebo$1@f04n12.cac.psu.edu>

Bob Spooner wrote:

> Well, it's not _quite_ that simple...
> "Michael Paus" <pausnospam@nospamib-paus.com> 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



      reply	other threads:[~2005-04-17 15:35 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-13 15:07 Using GNAT.Sockets markwork66
2005-04-13 15:43 ` Duncan Sands
2005-04-15  9:04   ` markp
2005-04-15  9:25     ` Duncan Sands
2005-04-18  9:01       ` markp
2005-04-18 13:23         ` Michael Paus
2005-04-18 14:32           ` markp
2005-04-18 15:14             ` Adrien Plisson
2005-04-18 15:35               ` markp
2005-04-18 15:48                 ` Adrien Plisson
2005-04-18 17:06                   ` markp
2005-04-18 18:23                     ` markp
2005-04-18 20:45                     ` Eric Jacoboni
2005-04-18 21:30                       ` Pascal Obry
2005-04-18 23:00                         ` Eric Jacoboni
2005-04-19  7:04                           ` Pascal Obry
2005-04-19 17:36                           ` Björn Lundin
2005-04-19 19:08                             ` Eric Jacoboni
2005-04-18 13:51         ` Marc A. Criley
2005-04-14 14:45 ` Bob Spooner
2005-04-15  9:06   ` markp
2005-04-15 11:47     ` Michael Paus
2005-04-15 14:07       ` Bob Spooner
2005-04-17 15:35         ` Michael Paus [this message]
replies disabled

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