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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f0972757f30880f7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-12 08:49:18 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: benjamin_place@hotmail.com (Benjamin Place) Newsgroups: comp.lang.ada Subject: Re: Sockets - newbie at a brick wall Date: 12 Dec 2002 08:49:17 -0800 Organization: http://groups.google.com/ Message-ID: References: <3df85d10.3167644@news.demon.co.uk> NNTP-Posting-Host: 64.193.216.41 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1039711758 6699 127.0.0.1 (12 Dec 2002 16:49:18 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 12 Dec 2002 16:49:18 GMT Xref: archiver1.google.com comp.lang.ada:31746 Date: 2002-12-12T16:49:18+00:00 List-Id: john@assen.nospam.demon.co.uk (John McCabe) wrote in message news:<3df85d10.3167644@news.demon.co.uk>... > 1) Your use of Socket_Datagram with a Connect() call. Perhaps you > should try Socket_Stream sockets. I *knew* I was missing something basic - the fact that "connected datagrams" is a contradiction didn't even occur to me, though it should have. Thanks for the critique. Attached is corrected code for my_client.adb. This version works, and both client and server exit normally. -- my_client.adb with GNAT.Sockets; use GNAT.Sockets; with Ada.Text_IO; use Ada.Text_IO; procedure My_Client is Socket : Socket_Type; Server : Sock_Addr_Type; Channel : Stream_Access; begin -- Create a client-side socket. Raise Socket_Error on error. Create_Socket (Socket, Family_Inet, Socket_Datagram); -- Initialize sockaddr_in structure with -- server (remote) socket name Server := ( Addr => Addresses (Get_Host_By_Name ("newton.cannella.org"), 1), Port => 4134, Family => Family_Inet ); Channel := Stream (Socket, Server); String'Output (Channel, "Hello, world!"); Close_Socket (Socket); end My_Client;