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,8bbf2dbc48e08e2f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsinpeer00.lnd.ops.eu.uu.net!emea.uu.net!peer-uk.news.demon.net!kibo.news.demon.net!mutlu.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Question about Streams and UDP sockets using GNAT.Sockets Date: Wed, 19 Jul 2006 19:59:57 +0100 Organization: Pushface Message-ID: References: <1153215666.455584.201990@m73g2000cwd.googlegroups.com> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1153335596 28417 62.49.19.209 (19 Jul 2006 18:59:56 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Wed, 19 Jul 2006 18:59:56 +0000 (UTC) Cancel-Lock: sha1:4FpHGoDU+MtOfDf9DHhnCe0hASs= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) Xref: g2news2.google.com comp.lang.ada:5821 Date: 2006-07-19T19:59:57+01:00 List-Id: "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!