comp.lang.ada
 help / color / mirror / Atom feed
From: Eric Jacoboni <jaco@neottia.net>
Subject: Re: TCP/IP Sockets with GNAT.Sockets
Date: Tue, 03 May 2005 00:10:14 +0200
Date: 2005-05-03T00:10:14+02:00	[thread overview]
Message-ID: <030520050010146101%jaco@neottia.net> (raw)
In-Reply-To: 42769099$0$24172$ba620e4c@news.skynet.be

In article <42769099$0$24172$ba620e4c@news.skynet.be>, Adrien Plisson
<aplisson-news@stochastique.net> 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



  reply	other threads:[~2005-05-02 22:10 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-02  2:42 TCP/IP Sockets with GNAT.Sockets fabio de francesco
2005-05-02  5:58 ` Eric Jacoboni
2005-05-02 12:11 ` Adrien Plisson
2005-05-02 14:55   ` fabio de francesco
2005-05-02 16:10     ` Adrien Plisson
2005-05-02 17:56       ` Eric Jacoboni
2005-05-02 18:30         ` Poul-Erik Andreasen
2005-05-02 19:10           ` Simon Wright
2005-05-03 13:00             ` Poul-Erik Andreasen
2005-05-03 21:48               ` Simon Wright
2005-05-04  8:01               ` Character'First, ASCII.NUL and others (Was: Re: TCP/IP Sockets with GNAT.Sockets) Adrien Plisson
2005-05-04 13:40                 ` Poul-Erik Andreasen
2005-05-02 20:37           ` TCP/IP Sockets with GNAT.Sockets fabio de francesco
2005-05-02 20:52             ` Adrien Plisson
2005-05-03 12:04               ` fabio de francesco
2005-05-03 12:22                 ` Adrien Plisson
2005-05-03 13:17             ` Poul-Erik Andreasen
2005-05-02 20:44         ` Adrien Plisson
2005-05-02 22:10           ` Eric Jacoboni [this message]
2005-05-02 23:42             ` tmoran
2005-05-02 19:39     ` Björn
2005-05-02 20:22       ` fabio de francesco
2005-05-09  4:03         ` Dave Thompson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox