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=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a24:3a90:: with SMTP id m138-v6mr8799993itm.37.1522005461884; Sun, 25 Mar 2018 12:17:41 -0700 (PDT) X-Received: by 2002:a9d:16c3:: with SMTP id s3-v6mr2130247ots.13.1522005461618; Sun, 25 Mar 2018 12:17:41 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!weretis.net!feeder4.news.weretis.net!news.roellig-ltd.de!open-news-network.org!peer02.am4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!199-v6no3037401itl.0!news-out.google.com!j10-v6ni3606ite.0!nntp.google.com!u184-v6no3033141ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 25 Mar 2018 12:17:41 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:18f:900:f900:6600:6aff:fe37:6bdc; posting-account=3pYsyQoAAACcI-ym7XtMOI2PDU8gRZS5 NNTP-Posting-Host: 2601:18f:900:f900:6600:6aff:fe37:6bdc References: <64541efa-41ea-464b-bb60-06719f3c56ad@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <9989fdfe-3c88-449f-91c5-f3059c17d992@googlegroups.com> Subject: Re: TCP Server & Client From: Andrew Shvets Injection-Date: Sun, 25 Mar 2018 19:17:41 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Body-CRC: 1935788991 X-Received-Bytes: 2616 Xref: reader02.eternal-september.org comp.lang.ada:51202 Date: 2018-03-25T12:17:41-07:00 List-Id: On Sunday, March 25, 2018 at 4:22:32 AM UTC-4, Simon Wright wrote: > Andrew Shvets writes: > > > procedure TCP_Client is > [...] > > GNAT.Sockets.Create_Socket(Socket, GNAT.Sockets.Family_Inet, GNAT.Sockets.Socket_Stream); > > > GNAT.Sockets.Set_Socket_Option(Socket, GNAT.Sockets.Socket_Level, (GNAT.Sockets.Reuse_Address, True)); > > > GNAT.Sockets.Send_Socket(Socket, Data, Last, Address); > > If you look at the spec of GNAT.Sockets for a long time you will see > that there are 3 versions of Send_Socket, only 2 of which I would expect > to use, and you've chosen the wrong one (the last, datagram, > version). You need the second: > > procedure Send_Socket > (Socket : Socket_Type; > Item : Ada.Streams.Stream_Element_Array; > Last : out Ada.Streams.Stream_Element_Offset; > Flags : Request_Flag_Type := No_Request_Flag); > > More importantly, you've left out the Connect_Socket call (which is what > the server Accept_Socket call is waiting for). > > Check out the commentary at the beginning of g-socket.ads, look for > 'task body ping'. > > > Also, in TCP_Server, you should be calling Receive_Socket on Sock (the > new socket which is actually connected to TCP_Client). Thank you Simon. That did the trick.