From: Robert Love <rblove@airmail.net>
Subject: Re: Sockets Example Sought
Date: Sat, 24 Nov 2012 12:27:04 -0600
Date: 2012-11-24T12:27:04-06:00 [thread overview]
Message-ID: <2012112412270484092-rblove@airmailnet> (raw)
In-Reply-To: 17vopoh3g5mg4.jv11ioybge4k$.dlg@40tude.net
The statements about disposing of Data, what does Shutdown_Socket it
do? It seems to end my task and never reach the following Close_Socket
statement. If I leave it out, I see Close_Socket execute and the
program seems to run fine.
On 2012-11-23 22:40:59 +0000, Dmitry A. Kazakov said:
> On Fri, 23 Nov 2012 15:58:53 -0600, Robert Love wrote:
>
>> On 2012-11-23 18:32:52 +0000, Simon Wright said:
>>
>>> Robert Love <rblove@airmail.net> writes:
>>>
>>>> Does anyone have an example of a multi-client server in Ada they care
>>>> to share? It should use the Gnat.Sockets package. I've seen samples
>>>> but they don't seem complete, or at least my understanding isn't
>>>> complete<grin>.
>>>>
>>>> Thanks in advance.
>>>
>>> task body Server in http://goo.gl/bXVw7 ? (lines 59 .. 143)
>>
>> What happens at line 120, the else clause on if Server = Socket_Server?
>> Is that where data is read in on the socket?
>
> Socket-select might be a bit difficult to start with. Unless you expect
> hundreds of simultaneous connections, there is a much simpler pattern that
> uses 1-2 tasks (half- or full-duplex I/O) per connection with so-called
> blocking sockets:
>
> Client : Sock_Addr_Type;
> Server : Sock_Addr_Type;
> Socket : Socket_Type;
> Data : Socket_Type;
> begin
> Server.Addr := ...;
> Server.Port := ...;
> Create_Socket (Socket);
> Bind_Socket (Socket, Server);
> Listen_Socket (Socket);
> loop
> Accept_Socket (Socket, Data, Client);
> -- Start an I/O task, give it Data to communicate over.
> -- Client holds the address of the client. The task will
> -- dispose the socket Data calling Shutdown_Socket and
> -- then Close_Socket on it, when communication is over
> end loop;
>
>> I assume the client opens the socket and the server detects it, then at
>> various times the client makes data requests by sending string data.
>
> That happens later on when the client connects its socket. A client does:
>
> Create_Socket
> Bind_Socket -- Client address
> Connect_Socket -- Server address
> -- I/O
> Shutdown_Socket
> Close_Socket
>
> The server listening to a socket gets a new socket when its calls to
> Accept_Socket. Accept waits for a client to come. This happens per each
> connection, i.e. for each client connection there is one accept completed
> on the server side. After accept returned a socket, this socket and the
> client's socket are connected, so that when one side writes something into
> its socket another side reads that from the socket of its own.
next prev parent reply other threads:[~2012-11-24 18:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-23 17:17 Sockets Example Sought Robert Love
2012-11-23 18:32 ` Simon Wright
2012-11-23 21:58 ` Robert Love
2012-11-23 22:40 ` Dmitry A. Kazakov
2012-11-24 18:27 ` Robert Love [this message]
2012-11-24 21:01 ` Dmitry A. Kazakov
2012-11-27 3:37 ` Robert Love
2012-11-27 8:41 ` Dmitry A. Kazakov
2012-11-27 15:05 ` Mark Lorenzen
2012-11-23 23:08 ` Simon Wright
2012-11-28 4:43 ` anon
2012-11-30 5:04 ` Robert Love
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox