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.200.46.133 with SMTP id h5mr20754542qta.40.1509121585674; Fri, 27 Oct 2017 09:26:25 -0700 (PDT) X-Received: by 10.157.52.218 with SMTP id t26mr353343otd.10.1509121585638; Fri, 27 Oct 2017 09:26:25 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!feed.usenet.farm!feeder4.usenet.farm!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!k31no3332450qta.1!news-out.google.com!v14ni1651qtc.0!nntp.google.com!k31no3332445qta.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 27 Oct 2017 09:26:25 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2804:431:9719:f688:96de:80ff:fea0:aec5; posting-account=wgmHdgoAAAA-F7JItPEZjeXqFc0KdzEQ NNTP-Posting-Host: 2804:431:9719:f688:96de:80ff:fea0:aec5 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <2f5d2e23-b77c-4380-8afb-ce36f63545de@googlegroups.com> Subject: Re: alternative for buggy accept_socket to create a non-blocking version From: Daniel Norte Moraes Injection-Date: Fri, 27 Oct 2017 16:26:25 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:48602 Date: 2017-10-27T09:26:25-07:00 List-Id: Em quarta-feira, 25 de outubro de 2017 15:23:52 UTC-2, Matt Borchers escre= veu: > I have no choice but to use an old GNAT compiler -- version 6.3.0. In th= is 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 s= hould. >=20 > 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. >=20 > This is my foray into sockets programming and I don't fully understand al= l of the nuances yet. I tried setting the Receive_Timeout socket option bu= t it had no effect -- I don't think it does what I need anyway. This all s= eems pretty straight-forward assuming there is no bug in the non-blocking v= ersion of accept_socket, but I don't know how to work-around this bug. >=20 > I can imagine a pair of tasks in which one does the blocking accept (A) a= nd the other task (B) does the time-out. If the time-out occurs first, B w= ill 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 soluti= on. >=20 > Does anybody know of a good way to create a type of non-blocking accept_s= ocket? >=20 > My code basically is: >=20 > 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> s= el_stat ); > ... > loop > receive_socket( sock, data, last ); > ... > end loop; > close_socket( socket ); > end; >=20 > Thanks, > Matt Or you can use lib Anet. []'s Dani.