From: Simon Wright <simon@pushface.org>
Subject: Re: Question about Streams and UDP sockets using GNAT.Sockets
Date: Wed, 19 Jul 2006 19:59:57 +0100
Date: 2006-07-19T19:59:57+01:00 [thread overview]
Message-ID: <m2odvlh13m.fsf@grendel.local> (raw)
In-Reply-To: 1153215666.455584.201990@m73g2000cwd.googlegroups.com
"lekktu@gmail.com" <lekktu@gmail.com> writes:
> I'm trying to broadcast an UDP packet, with the following test code:
> The trouble I'm having is not about sockets, but the streams vs.
> sockets interaction. The above code does not send one UDP packet,
> but four, one for each byte of the test message. What I'm doing
> wrong?
If you tried to read the data you would probably not have noticed
anything wrong; because GNAT (GNAT.Sockets, anyway) is rather naive
about UDP sockets. It would have happily done 4 reads, one for each
byte of the test message.
The only way I can see to get UDP working is
(1) stream the record to be output to a memory stream,then write the
bytes of the stream to the socket stream in one go;
(2) read a datagram into a maximally-sized Stream Element Array (1600
bytes or so?), populate a memory stream with the bytes actually
read, read the record to be input from that.
Personally I think that letting us get a Stream for a GNAT.Sockets
datagram socket is almost bound to result in error and shouldn't be
allowed, I couldn't persuade AdaCore of that!
next prev parent reply other threads:[~2006-07-19 18:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-18 9:41 Question about Streams and UDP sockets using GNAT.Sockets lekktu
2006-07-18 9:55 ` Dmitry A. Kazakov
2006-07-18 10:25 ` Alex R. Mosteo
2006-07-18 11:02 ` lekktu
2006-07-18 14:25 ` Alex R. Mosteo
2006-07-18 14:58 ` lekktu
2006-07-18 20:52 ` Samuel Tardieu
2006-07-18 20:58 ` Randy Brukardt
2006-07-19 10:36 ` Alex R. Mosteo
2006-07-19 18:50 ` Simon Wright
2006-07-18 19:07 ` Jeffrey R. Carter
2006-07-18 20:13 ` Dmitry A. Kazakov
2006-07-19 0:32 ` Jeffrey R. Carter
2006-07-19 8:12 ` Dmitry A. Kazakov
2006-07-19 18:59 ` Simon Wright [this message]
2006-07-19 20:54 ` lekktu
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox