title: How to send then receive packet from Client-Server in Ada
body: <p>I want to create a server-client connection where a client send a request packet to the server then return a value back to the user. I can get the server to read the incoming packet from the client, but when it write back to the client, the client is not receiving the packet. </p>
  
  <p>I have the size of string in Client and Server matches to ensure the read is not waiting for more incoming packet. </p>
  
  <p>Server</p>
  
  <pre><code>Buffer : Ada.Streams.Stream_Element_Array (1 .. 10);
  Offset : Ada.Streams.Stream_Element_Offset;
  ...
  GNAT.Sockets.Create_Socket (Socket =&gt; Receiver);
  GNAT.Sockets.Set_Socket_Option
      (Socket =&gt; Receiver,
      Option =&gt; (Name    =&gt; GNAT.Sockets.Reuse_Address, Enabled =&gt; True));
  GNAT.Sockets.Bind_Socket
      (Socket  =&gt; Receiver,
          Address =&gt; (Family =&gt; GNAT.Sockets.Family_Inet,
          Addr   =&gt; GNAT.Sockets.Inet_Addr ("127.0.0.1"),
          Port   =&gt; 12321));
  GNAT.Sockets.Listen_Socket (Socket =&gt; Receiver);
  GNAT.Sockets.Accept_Socket
      (Server  =&gt; Receiver,
       Socket  =&gt; Connection,
       Address =&gt; Client);
  Channel := GNAT.Sockets.Stream (Connection);
  Ada.Streams.Read(Stream =&gt; Channel.all,
                    Item =&gt; Buffer,
                    Last =&gt; Offset);
  for J in 1..Offset loop
      Ada.Text_IO.Put_Line(Character'Val(Integer (Buffer (J)))'Img);
  end loop;
  String'Write(GNAT.Sockets.Stream (Connection), "1234567890");
  GNAT.Sockets.Close_Socket (Connection);
  </code></pre>
  
  <p>Client</p>
  
  <pre><code>input : String(1..10);
  output : String(1..10);
  ...
  Initialize;
  Create_Socket  (Socket =&gt; Client);
  Connect_Socket (Socket   =&gt; Client,
  Server   =&gt; (Family =&gt; Family_Inet,
      Addr   =&gt; Inet_Addr ("127.0.0.1"),
      Port   =&gt; 12321));
  String'Write (Stream (Client), Input);
  String'Read (Stream (Client), output); --hanging right here
  Close_Socket (Client);
  </code></pre>