comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Creem <jeff@thecreems.com>
Subject: Re: How to implement a server socket compatible to telnet?
Date: Fri, 08 Aug 2008 13:15:00 GMT
Date: 2008-08-08T13:15:00+00:00	[thread overview]
Message-ID: <sprtm5-lup.ln1@newserver.thecreems.com> (raw)
In-Reply-To: <ca7b2304-6726-479b-89a0-67486c3dc06f@f63g2000hsf.googlegroups.com>

snoopysalive@googlemail.com wrote:
> Hello!
> 
> For some reasons I had to implement a server socket in C++. Now I want
> to do the same in Ada and so I read the GNAT.Sockets-library and
> implemented a shorter version of the example given in the g-
> socket.ads.
> 
> The problem is that I want to implement the server in a kind, that
> processes written in other languages like the tool telnet or a Java-
> programme are able to communicate with it. But my server isn't able to
> print a message sent by the telnet-client, so I think that I've
> written something wrong in my code.
> 


You don't show the client code but if you really really mean it is a 
telnet client then your problem is that  you are using 'input. Look at 
the LRM definitions for these. (looking at ada 95 here for a moment, 
ARM95-13-13-2)

S'Input reads and returns one value from Stream, using any bounds or 
discriminants written by a corresponding S'Output to determine how much 
to read.

So, unless your telnet client is Ada aware and is sending strings 
formatted per Ada string semantics with bounds, then this can't work. 
The example you started from probably had a client and server who had 
agreed upon a protocol that used 'input 'output semantics.

Telnet has not agreed to this protocol.

There are plenty of ways to do what you are trying.

You could probably play around with 'read 'write on characters or with

  procedure Receive_Socket
      (Socket : Socket_Type;
       Item   : out Ada.Streams.Stream_Element_Array;
       Last   : out Ada.Streams.Stream_Element_Offset);

or with a custom overloaded 'read that you implement with something like 
Receive_Socket depending upon what you are trying to accomplish.



  reply	other threads:[~2008-08-08 13:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-08 11:31 How to implement a server socket compatible to telnet? snoopysalive
2008-08-08 13:15 ` Jeffrey Creem [this message]
2008-08-08 13:35 ` Alex R. Mosteo
2008-08-08 16:24 ` anon
2008-08-09 13:19   ` snoopysalive
2008-08-10 22:15   ` Robert A Duff
2008-08-10 23:34     ` anon
2008-08-11  1:31       ` Robert A Duff
2008-08-11 18:26         ` anon
2008-08-11 18:59           ` Samuel Tardieu
2008-08-20 21:25             ` snoopysalive
2008-08-20 22:57               ` anon
replies disabled

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