comp.lang.ada
 help / color / mirror / Atom feed
From: "Bob Spooner" <rls19@psu.edu>
Subject: Re: Using GNAT.Sockets
Date: Thu, 14 Apr 2005 10:45:31 -0400
Date: 2005-04-14T10:45:31-04:00	[thread overview]
Message-ID: <d3lvmh$hb0$1@f04n12.cac.psu.edu> (raw)
In-Reply-To: 1113404846.310840.322920@z14g2000cwz.googlegroups.com

Hi Markwork66,

<markwork66@yahoo.com> wrote in message
news:1113404846.310840.322920@z14g2000cwz.googlegroups.com...
> We are just converting to GNAT and I am used to the traditional TCP
> send/receive using an address and byte count to send/receive data. I've
> used the Receive_Socket command in GNAT.Sockets and I am having trouble
> receiving all the bytes. The "Last" parameter is not always equal to
> the size of the message I'm sending and I don't see a way to call back
> into the procedure to receive the rest of the bytes.
>
> Further, we have many different sized messages and, from my little
> playing with GNAT sockets, it seemed the "Item" parameter is the only
> way to specify the number of bytes you want to receive. So, does that
> mean I would have to declare an array of bytes (the "Item" parameter)
> for all of my messages and the then do an unchecked conversion or a
> copy_bytes routine to get the data into my Ada message data type?
>
> Any help anybody could provide would be most appreciated.
>
I'm assuming that you are using TCP/IP, which is a stream-oriented protocol.
The messages you are sending may be broken up into shorter lengths depending
on the characteristics of the underlying mechanism used for moving the
information. There are several solutions to your problem, among them:

1) If you are using the same compiler and type of computer, operating
system, etc. at both ends of the circuit, you can use the default streams
mechanism to send the messages by using the Input and Output attributes.
Unlike C++, the default representation format for the streams facility for
Ada is binary rather than ASCII.

2) You can layer a record protocol on top of TCP/IP where you prepend your
message with a fixed-length integer field representing the number of bytes
in the message. Then when you receive the message, you first read the number
of bytes, and then issue additional reads until you have received the entire
message.

I hope this helps.

Bob





  parent reply	other threads:[~2005-04-14 14:45 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 [this message]
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
replies disabled

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