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,7db5fb0599fd4b76 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!news.tele.dk!not-for-mail Date: Tue, 03 May 2005 15:17:19 +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> <427671d4$0$166$edfadb0f@dread11.news.tele.dk> <1115066261.409185.133090@o13g2000cwo.googlegroups.com> In-Reply-To: <1115066261.409185.133090@o13g2000cwo.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <427779df$0$192$edfadb0f@dread11.news.tele.dk> Organization: TDC Totalloesninger NNTP-Posting-Host: 80.166.145.174 X-Trace: 1115126239 dread11.news.tele.dk 192 80.166.145.174:14386 X-Complaints-To: abuse@post.tele.dk Xref: g2news1.google.com comp.lang.ada:10897 Date: 2005-05-03T15:17:19+02:00 List-Id: fabio de francesco wrote: > Poul-Erik Andreasen wrote: > >>[...] >> >>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: > > > How can you know a priori if a remote service is coded in C or Ada or > everything else? You can't, but i make no differens as long as you have the API. If the API requires zeroterminated strings it what you could call a c-style API. It can be written in any langauge, also in Ada and ' still be a C.style > >>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; > > > Is your code reading character by character? If it is I don't think you > can use it for designing efficient programs. At some level the program vill have to deal with bytes individualy anyway, you could asume that the build in procedure are better optimized, but i dont think that the overhead is significant as long as you use a fixed string as buffer. If you using unbounded_strings, and are adding the incomming character it is a quite different story; > >>BTW my C-couterpart program dosn't seems to have anything against >>String'Output( Channel, "Hello" & character'first) ? > > > What I understand from this thread is that T'Output and T'Input add > some metadata to the stream. If it is true, communicating programs in > other languages must know how to read/write the streams in order to > differentiate data from metadata. May be your C-counterpart program > contains an algorithm that knows how to do it. Yes it requere a special start character. Greeting Poul-Erik Andreasen