comp.lang.ada
 help / color / mirror / Atom feed
From: Daniel Norte Moraes <danielcheagle@gmail.com>
Subject: Re: alternative for buggy accept_socket to create a non-blocking version
Date: Fri, 27 Oct 2017 09:26:25 -0700 (PDT)
Date: 2017-10-27T09:26:25-07:00	[thread overview]
Message-ID: <2f5d2e23-b77c-4380-8afb-ce36f63545de@googlegroups.com> (raw)
In-Reply-To: <fde3b429-3d55-4dbf-8183-d6ffc5137e01@googlegroups.com>

Em quarta-feira, 25 de outubro de 2017 15:23:52 UTC-2, Matt Borchers  escreveu:
> I have no choice but to use an old GNAT compiler -- version 6.3.0.  In this version there is a confirmed bug (fixed in 6.3.2) that prevents the non-blocking version of accept_socket from working.  I want to call the version of accept_socket with the 'timeout' parameter, but it doesn't do what it should.
> 
> Basically, I've built a way to read data from a socket and all goes well when a response is made.  However, I need a way to abandon the accept call if a response is never sent within a small time window.
> 
> This is my foray into sockets programming and I don't fully understand all of the nuances yet.  I tried setting the Receive_Timeout socket option but it had no effect -- I don't think it does what I need anyway.  This all seems pretty straight-forward assuming there is no bug in the non-blocking version of accept_socket, but I don't know how to work-around this bug.
> 
> I can imagine a pair of tasks in which one does the blocking accept (A) and the other task (B) does the time-out.  If the time-out occurs first, B will abort the task A otherwise after A succeeds in accepting the message it will abort B.  This seems like it might not be the best work-around solution.
> 
> Does anybody know of a good way to create a type of non-blocking accept_socket?
> 
> My code basically is:
> 
> with GNAT.Sockets; use GNAT.Sockets;
> ...
> declare
>   sock,
>   socket   : SOCKET_TYPE;
>   address  : SOCK_ADDR_TYPE;
>   data     : STREAM_ELEMENT_ARRAY(1..256);
>   last     : STREAM_ELEMENT_OFFSET;
>   sel_stat : SELECTOR_STATUS;
> begin
>   create_socket( socket );
>   bind_socket( socket, address );
>   listen_socket( socket );
>   accept_socket( socket, sock, address );
>   --I wish I could do this
>   --accept_socket( socket, sock, address, timeout => 2.0, status => sel_stat );
>   ...
>   loop
>     receive_socket( sock, data, last );
>     ...
>   end loop;
>   close_socket( socket );
> end;
> 
> Thanks,
> Matt

Or you can use lib Anet.

[]'s Dani.

      parent reply	other threads:[~2017-10-27 16:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-25 17:23 alternative for buggy accept_socket to create a non-blocking version Matt Borchers
2017-10-25 19:14 ` Matt Borchers
2017-10-26 13:43   ` Shark8
2017-10-25 19:18 ` Dmitry A. Kazakov
2017-10-27  9:14 ` Björn Lundin
2017-10-27 23:46   ` Matt Borchers
2017-10-27 16:26 ` Daniel Norte Moraes [this message]
replies disabled

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