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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,61ec2c598155da95 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!k41g2000yqh.googlegroups.com!not-for-mail From: Tony Newsgroups: comp.lang.ada Subject: Re: Aborting a call to Accept_Socket Date: Tue, 21 Apr 2009 09:32:07 -0700 (PDT) Organization: http://groups.google.com Message-ID: <2af019a2-5f01-4068-9ce3-ec84d212cee3@k41g2000yqh.googlegroups.com> References: <44d6b044-3cb8-402c-9b1f-afe39f6a47ce@r33g2000yqn.googlegroups.com> <5v74txgo3q9d$.cj2k983k72sh$.dlg@40tude.net> NNTP-Posting-Host: 83.167.145.210 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1240331527 1475 127.0.0.1 (21 Apr 2009 16:32:07 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 21 Apr 2009 16:32:07 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k41g2000yqh.googlegroups.com; posting-host=83.167.145.210; posting-account=NPvXCgoAAACeAnV0vTvzXKjbTtI1j27n User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:5517 Date: 2009-04-21T09:32:07-07:00 List-Id: On 21 avr, 18:21, "Dmitry A. Kazakov" wrote: > On Tue, 21 Apr 2009 08:40:13 -0700 (PDT), Tony wrote: > > I would like to abort a call to Accept_Socket() if no connection > > request arrives within a specified time (20 seconds). =A0For me, a quit= e > > simple solution (perhaps not safe) is to use an asynchronous transfer > > of control like this: > > --**************************************************** > > =A0 =A0procedure Server is > > =A0 =A0 =A0 =A0... > > =A0 =A0begin > > =A0 =A0 =A0 =A0GNAT.Sockets.Initialize; > > =A0 =A0 =A0 =A0... > > =A0 =A0 =A0 =A0loop > > =A0 =A0 =A0 =A0 =A0 =A0... > > =A0 =A0 =A0 =A0 =A0 =A0select > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0delay 20.0; > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0exit; > > =A0 =A0 =A0 =A0 =A0 =A0then abort > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0GNAT.Sockets.Accept_Socket (...); > > =A0 =A0 =A0 =A0 =A0 =A0end select; > > =A0 =A0 =A0 =A0 =A0 =A0... > > =A0 =A0 =A0 =A0end loop ; > > =A0 =A0end Server; > > --**************************************************** > > The expecting behaviour was the end of the program after 20 seconds > > (if no connection request arrives). I observe : after 20 seconds the > > program will terminate only if =A0a connection request arrives. > > Is this behaviour correct? > > Yes, it is. Asynchronous transfer of control is not guaranteed to work wi= th > an outstanding calls. Most likely it does not work as in this case. The > behavior is correct because Ada does not know how to abort a socket > operation in order to implement this statement. Ada RM contains a list of > abort deferred things, which includes potentially any call to any externa= l > operation. Specifically for sockets there is a solution: you close the > socket from another task. That will kill accept with an error code. > > -- > Regards, > Dmitry A. Kazakovhttp://www.dmitry-kazakov.de That's what I suspected, thanks a lot for your confirmation. Regards. Tony.