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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ad2e14b28c224ca9 X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news1.google.com!news.glorb.com!fr.ip.ndsoftware.net!proxad.net!proxad.net!194.159.246.34.MISMATCH!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: gnat sockets problem Date: 30 May 2004 12:06:58 +0100 Organization: Pushface Sender: simon@smaug.pushface.org Message-ID: References: <4d01ad29.0405291608.6d71cd4@posting.google.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 1085915498 17264 62.49.19.209 (30 May 2004 11:11:38 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sun, 30 May 2004 11:11:38 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: controlnews3.google.com comp.lang.ada:928 Date: 2004-05-30T12:06:58+01:00 List-Id: mutilation@bonbon.net (wave) writes: > loop > declare > Message : String := String'Input (Channel); > begin > Put (Message); > end; > end loop; Tom has given you a suggestion for the send part. For the receive part, you need to read the whole datagram at one go, so you mustn't use the stream attributes ('Read, 'Input even) on a network socket stream (for a record type, each non-elementary component of the stream ends up in a recvFrom() from the socket!). The same is true in reverse for 'Write; avoid it for UDP! Instead, use GNAT.Sockets.Receive_Socket (I've used the second form when receiving UDP messages): procedure Receive_Socket (Socket : Socket_Type; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; From : out Sock_Addr_Type); to read into a Stream_Element_Array of the appropriate maximum size you are expecting; no harm really in choosing the max size of a UDP datagram, 1500 bytes or so, unless Quake uses a smaller max size. Once you have the Stream_Element_Array you can read the bounds etc from it and use unchecked conversion (or overlay) to get at the actual fields. -- Simon Wright 100% Ada, no bugs.