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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: TCP Server & Client Date: Sun, 25 Mar 2018 09:22:29 +0100 Organization: A noiseless patient Spider Message-ID: References: <64541efa-41ea-464b-bb60-06719f3c56ad@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="17e764f05edab12536e8b08e4bd81bc5"; logging-data="31166"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+CH3Maci519WomroGGhYIiMwc6VgCXgZU=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (darwin) Cancel-Lock: sha1:rHFfB69259FnTpDEuOz2UBwrFgA= sha1:ejhIN3QsZnbN2DQUgUmfYsW4UBY= Xref: reader02.eternal-september.org comp.lang.ada:51196 Date: 2018-03-25T09:22:29+01:00 List-Id: 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).