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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.36.137.130 with SMTP id s124mr1635227itd.30.1508952230438; Wed, 25 Oct 2017 10:23:50 -0700 (PDT) X-Received: by 10.157.0.7 with SMTP id 7mr108357ota.14.1508952230402; Wed, 25 Oct 2017 10:23:50 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!newspeer1.nac.net!border2.nntp.dca1.giganews.com!nntp.giganews.com!l196no5538462itl.0!news-out.google.com!p6ni1349itp.0!nntp.google.com!k70no5549046itk.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 25 Oct 2017 10:23:50 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=192.160.103.137; posting-account=1tLBmgoAAAAfy5sC3GUezzrpVNronPA- NNTP-Posting-Host: 192.160.103.137 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: alternative for buggy accept_socket to create a non-blocking version From: Matt Borchers Injection-Date: Wed, 25 Oct 2017 17:23:50 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:48591 Date: 2017-10-25T10:23:50-07:00 List-Id: 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-bl= ocking version of accept_socket from working. I want to call the version o= f accept_socket with the 'timeout' parameter, but it doesn't do what it sho= uld. Basically, I've built a way to read data from a socket and all goes well wh= en 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 see= ms pretty straight-forward assuming there is no bug in the non-blocking ver= sion 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 wil= l abort the task A otherwise after A succeeds in accepting the message it w= ill 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_soc= ket? 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 =3D> 2.0, status =3D> sel= _stat ); ... loop receive_socket( sock, data, last ); ... end loop; close_socket( socket ); end; Thanks, Matt