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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3d824959ef461baa X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-03 18:03:53 PST Path: archiver1.google.com!news2.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!intern1.nntp.aus1.giganews.com!nntp.giganews.com!nntp.clear.net.nz!news.clear.net.nz.POSTED!not-for-mail NNTP-Posting-Date: Fri, 03 Oct 2003 20:03:51 -0500 From: Craig Carey Newsgroups: comp.lang.ada Subject: Re: task blocked using GNATSOCKETS Date: Sat, 04 Oct 2003 13:03:53 +1200 Message-ID: <383snvonam93meek6vsrbqsr35j4kbdnem@4ax.com> References: X-Newsreader: Forte Agent 1.92/32.572 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Organization: Customer of Mercury Telecommunications Ltd Cache-Post-Path: drone5.qsi.net.nz!unknown@tnt2-138.quicksilver.net.nz X-Cache: nntpcache 2.4.0b5 (see http://www.nntpcache.org/) X-Original-NNTP-Posting-Host: drone5-svc-skyt.qsi.net.nz X-Original-Trace: 4 Oct 2003 13:03:53 +1200, drone5-svc-skyt.qsi.net.nz NNTP-Posting-Host: 203.97.37.6 X-Trace: sv3-C8Wmq6Co9QY3hhFpxa1KKO2ZqI/gd+JNqT7CmHJJEk4dx0PqD6HJPrs9WS4lFu+b9D8J1+zsiOXSCoT!GvSdBh34BHKRWd7btHWVp1BIR5yoDLgx9tXdppA0ChV1OMqzPbJpz3rCpixSAjEPbnoBuk0YWT2W!nJ4lNGY= X-Complaints-To: Complaints to abuse@clear.net.nz X-DMCA-Complaints-To: Complaints to abuse@clear.net.nz X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: archiver1.google.com comp.lang.ada:187 Date: 2003-10-04T13:03:53+12:00 List-Id: On Fri, 3 Oct 2003 11:52:27 +0200, "Riccardo Fulcoli" wrote: ... >In particular if another program has already a socket on a particular >address and port that I want to use no errors messages are presented but my >task simply waits indefinitely. > >In the other hand if I use the same code in a procedure that is not a task I >can get the exception: > >"raised GNAT.SOCKETS.SOCKET_ERROR : [125] Address already in use" That could be a problem due to Linux. If Linux, some comment on FSU GNAT threads vs RTS threads would be appropriate. In Linux, netstat can be run (and in Windows, TCP Viewer of www.sysinternals.com), and that can show if the port number (interface) is locked up. The SO_REUSEADDR flag might possibly fix the program GS.Set_Socket_Option (Socket => So_Sock, Level => GS.Socket_Level, -- SOL_SOCKET Option => GS.Option_Type'( -- SO_REUSEADDR Name => GS.Reuse_Address, Enabled => Share), Error_Val => Error_Val); In Linux reducing the Time_Wait interval for a single socket does nothing. In Windows a port number can be bound to before another program actually released it. Then the other program can be killed. * create socket * bind to socket * when when no error * produce error message saying interface is in use or in Time_Wait state. * set SO_REUSEADDR * bind again (and reusing the same socket seems to no worse) Also every socket can have SO_REUSEADDR set. Then port numbers connected to, are not themselves locked up for 1 minute after the program (or fragment) quits. It seems to be a bug in Linux (maybe ported over from BSD). -- Zombie Ada program fragments can lock up sockets. There could be a special port number that all live and zombies GNAT Ada programs chat over, and their coordinate the killing of each other which then could free up port numbers. The GNAT Pro compiler seems to have a solution now. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9480 | FYI, in the ACT GNATpro version 5.00a, there is a new pragma | Interrupt_State which fixes this problem. | | When that pragma is inserted as shown below, the tasking program | can be killed via the TERM signal as expected: | | procedure Sigterm is | pragma Unreserve_All_Interrupts; | pragma Interrupt_State (SIGTERM, System); -- insert this line The 'killall' command can succesfully clean up after a Ctrl-C. Actually, this feature of Ada could speed up testing of university assignments: if the code starts but does not stop then there might be a rule allowing no further checking. Craig Carey