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!news.glorb.com!news.agarik.com!teaser.fr!titine.scrogneugneu.org!jaco From: Eric Jacoboni Newsgroups: comp.lang.ada Subject: Re: TCP/IP Sockets with GNAT.Sockets Date: Tue, 03 May 2005 00:10:14 +0200 Organization: Rogntudju & Associates Message-ID: <030520050010146101%jaco@neottia.net> 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> <42769099$0$24172$ba620e4c@news.skynet.be> NNTP-Posting-Host: 192.168.2.3 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: titine.scrogneugneu.org 1115071953 13929 192.168.2.3 (2 May 2005 22:12:33 GMT) X-Complaints-To: usenet@titine.scrogneugneu.org NNTP-Posting-Date: Mon, 2 May 2005 22:12:33 +0000 (UTC) User-Agent: Thoth/1.7.2 (Carbon/OS X) Xref: g2news1.google.com comp.lang.ada:10890 Date: 2005-05-03T00:10:14+02:00 List-Id: In article <42769099$0$24172$ba620e4c@news.skynet.be>, Adrien Plisson wrote: > this is my Ada client: Thanks, i'm gonna try to adapt it to my needs... > ========================================================================= > with Ada.Text_IO, > GNAT.Sockets; > procedure Main is > use GNAT.Sockets; > > Address : Sock_Addr_Type := (Family_Inet, Inet_Addr( "127.0.0.1" > ), 5555); > Socket : Socket_Type; > Channel : Stream_Access; > > Data : String := "hello"; > > begin > Initialize; > Create_Socket( Socket ); > Connect_Socket( Socket, Address ); > Channel := Stream( Socket ); > > String'Write( Channel, Data ); > String'Read( Channel, Data ); > Ada.Text_IO.Put_Line( Data ); > > Close_Socket( Socket ); > Finalize; > end Main; > as i already pointed to you on fr.comp.lang.ada, what you get from a > read is dependant on the PROTOCOL ! Well... Given the POP3 RFC: "Responses in the POP3 consist of a status indicator and a keyword possibly followed by additional information. All responses are terminated by a CRLF pair. Responses may be up to 512 characters long, including the terminating CRLF. " So, i understand i have to read in a string and that's how i do with every language i know. The pb with your exemple is that you have wrote both the server and the client : you know the server will always send fixed length strings, but that's not the case in real life. Sometimes the POP3 server will send a "+OK", sometimes a "+OK 20 40", sometimes another string. The protocol itself doesnt convey the length of the answer and that's also true with other well known Internet protocols. How to manage this with a Ada String ? I admit i don't see how to do. > ultimately, you can > combine all the techniques to define powerful language-independant > protocols ! I don't want to define protocols, i just want be able to use an existing protocol and to speak with a server that follow a well known RFC. -- jaco