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,99ad16995c7745f2 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!cyclone1.gnilink.net!spamkiller.gnilink.net!gnilink.net!trnddc01.POSTED!c9e1c1fe!not-for-mail From: Jeffrey Creem User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How to implement a server socket compatible to telnet? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Fri, 08 Aug 2008 13:15:00 GMT NNTP-Posting-Host: 71.181.42.14 X-Complaints-To: abuse@verizon.net X-Trace: trnddc01 1218201300 71.181.42.14 (Fri, 08 Aug 2008 09:15:00 EDT) NNTP-Posting-Date: Fri, 08 Aug 2008 09:15:00 EDT Xref: g2news1.google.com comp.lang.ada:1542 X-Original-Bytes: 2710 Date: 2008-08-08T13:15:00+00:00 List-Id: 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.