comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Finding the end of a stream from a socket
Date: Sat, 21 Oct 2017 21:19:30 +0200
Date: 2017-10-21T21:19:30+02:00	[thread overview]
Message-ID: <osg6k3$h1a$1@gioia.aioe.org> (raw)
In-Reply-To: 783nuc1ap2d5dqbuqgimm6igket7ecjeo9@4ax.com

On 2017-10-21 20:11, Dennis Lee Bieber wrote:
> On Sat, 21 Oct 2017 06:45:22 -0700 (PDT), Andrew Shvets
> <andrew.shvets@gmail.com> declaimed the following:
> 
>>   GNAT.Sockets.Bind_Socket(Receiver, (GNAT.Sockets.Family_Inet, GNAT.Sockets.Inet_Addr("127.0.0.1"), 50000));
>>   GNAT.Sockets.Listen_Socket(Receiver);
>>
> 	From those statements I'm guessing you are trying to set this program
> up as a server, and have some other program which will connect to send data
> to this one.
> 
>>   Ada.Text_IO.Put_Line(" !! TCP Server started !!");
>>
>>   loop
>>     Ada.Text_IO.Put_Line(" FOO 1");
>>     GNAT.Sockets.Connect_Socket(Receiver,  Client_Addr);
> 
> 	But here you are saying /this/ program is going to connect to a server
> at (undefined) Client_Addr.
> 
> 	I suspect you really need to be using g.s.Accept_Socket() instead.

Also note that Accept_Socket will return another socket. This one you 
should use for communication.

A typical scenario for blocking sockets:

    loop -- Connection listening
       Accept_Socket -- Get communication socket
       Start a new session task with the communication socket
    end loop;

The session task deals with the connection using the socket returned by 
Accept_Socket. Once the session is complete it closes that socket and 
terminates.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  reply	other threads:[~2017-10-21 19:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-21  2:05 Finding the end of a stream from a socket Andrew Shvets
2017-10-21  8:44 ` Dmitry A. Kazakov
2017-10-21 13:45   ` Andrew Shvets
2017-10-21 18:11     ` Dennis Lee Bieber
2017-10-21 19:19       ` Dmitry A. Kazakov [this message]
2017-10-21 19:46         ` Andrew Shvets
2017-10-22 12:26         ` Andrew Shvets
2017-10-22 12:28           ` Andrew Shvets
2017-10-22 13:28           ` Dmitry A. Kazakov
2017-10-21 17:34   ` Andrew Shvets
2017-10-21 19:18     ` Andrew Shvets
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox