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,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7db5fb0599fd4b76 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news4.google.com!news.glorb.com!news.tele.dk!not-for-mail Date: Mon, 02 May 2005 20:30:44 +0200 From: Poul-Erik Andreasen User-Agent: Mozilla Thunderbird 0.8 (X11/20040926) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: TCP/IP Sockets with GNAT.Sockets References: <1115001752.291144.218410@z14g2000cwz.googlegroups.com> <427618e9$0$7743$ba620e4c@news.skynet.be> <1115045740.838321.306480@g14g2000cwa.googlegroups.com> <42765108$0$22419$ba620e4c@news.skynet.be> <020520051956181888%jaco@neottia.net> In-Reply-To: <020520051956181888%jaco@neottia.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <427671d4$0$166$edfadb0f@dread11.news.tele.dk> Organization: TDC Totalloesninger NNTP-Posting-Host: 80.166.145.174 X-Trace: 1115058644 dread11.news.tele.dk 166 80.166.145.174:52213 X-Complaints-To: abuse@post.tele.dk Xref: g2news1.google.com comp.lang.ada:10880 Date: 2005-05-02T20:30:44+02:00 List-Id: Eric Jacoboni wrote: > In article <42765108$0$22419$ba620e4c@news.skynet.be>, Adrien Plisson > wrote: > > > >>>S : String := "Hello"; >>>SEA : Stream_Element_Array(1..S'Length); >>>for SEA'Address use S(S'First)'Address; >>>Last : Stream_Element_Offset; >>>Send_Socket( Socket, SEA, Last ); >> >>(i'm sorry i'm gonna be a bit rude) beuark ! > > > Agree. It's not the sort of things i expected to write with Ada... But, > that's the only code that fits my needs. > > >>this is implementation dependant: >>- what if Character'Size /= Stream_Element'Size ? >>- what if the memory organization of Stream_Element_Array does not >>match the one for a String ? > > > For the second point, Stream_Element_Array is defined as an array of > Stream_Element, so i suppose it match the memory organization of a > String, isn't it ? > > >>you'd better write this: >> >>declare >> Socket : Socket_Type; >> Channel : Stream_Access; >>begin >> -- open your socket here, then... >> Channel := Stream( Socket ); >> >> String'Write( Channel, "Hello" ); >> -- close your socket here... >>end; > > > Have you tried this code with a server not Ada aware? Have you tried to > exchange messages with, say, a POP3 server? (to send and to read) I've > tried to use Streams for that, but i never succeeded to make it work... > If a cleaner solution exists, why the hell cannot we find _any_ > example? > I have, actually i am using it rigth now and i works. however If the other end of the socket is a C-style server it will probely demand somthing like the following: String'Write( Channel, "Hello" & character'first); when i read i read characters and stop when i reach character'first. Here is a fixed string sulution declare Channel := Stream( Socket ); Word : string(1.. max_word); counter : natural := 1 begin loop word(counter) := Character'Input (Channel); exit when word(counter) = Character'First; counter := counter + 1; end loop; -- her do what you have to do with Word(1..(counter -1)) end; BTW my C-couterpart program dosn't seems to have anything against String'Output( Channel, "Hello" & character'first) ?