From: David A. <dav...@gm...> - 2008-10-07 17:56:16
|
David Ruggles wrote: > How would I specify a timeout? Sockaccept doesn't seem to have an argument > for timeout. > > Thanks, > > David Ruggles > CCNA MCSE (NT) CNA A+ > Network Engineer Safe Data, Inc. > (910) 285-7200 da...@sa... > > > > -----Original Message----- > From: David Ashley [mailto:dav...@gm...] > Sent: Tuesday, October 07, 2008 12:07 PM > To: Open Object Rexx Developer Mailing List > Subject: Re: [Oorexx-devel] Sockets on Linux > > > David Ruggles wrote: > >> I saw that Mark modified the socket samples to include the shebang line so >> you can execute them on Linux. >> >> Well I realized I hadn't tested them on Linux so I have started to do >> > that. > >> I ran in to an issue, but I don't know if it is something we can fix or >> > not. > >> When you issue a sockaccept it will hang the thread waiting for a new >> connection. On windows, if you issue a sockclose from another thread >> sockaccept returns an error which you can trap and use to shutdown >> > cleanly. > >> On Linux, sockaccept ignores the sockclose and still wait for a >> > connection. > >> If you connect to the server, the next call to sockaccept (after the call >> > to > >> sockclose) will fail and everything will shutdown. >> >> I am using the 3.2 to do the testing if that makes a difference. >> >> Thanks, >> >> David Ruggles >> CCNA MCSE (NT) CNA A+ >> Network Engineer Safe Data, Inc. >> (910) 285-7200 da...@sa... >> >> >> >> ------------------------------------------------------------------------- >> This SF.Net email is sponsored by the Moblin Your Move Developer's >> > challenge > >> Build the coolest Linux based applications with Moblin SDK & win great >> > prizes > >> Grand prize is a trip for two to an Open Source event anywhere in the >> > world > >> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> _______________________________________________ >> Oorexx-devel mailing list >> Oor...@li... >> https://lists.sourceforge.net/lists/listinfo/oorexx-devel >> >> >> > David - > > The way Windows allows a close operation on an essentially busy socket > is in strict violation of the POSIX standard for sockets. The method > that should be used is to add a timeout to the accept operation so that > the socket is not busy and a close operation has a chance to work. Most > *nix server application I have worked on add a 3 minute timeout on the > accept operation and then loop back and do another accept operation > after some housekeeping is performed. They usually coordinate a close > operation on the sever socket with an event semaphore that is read > during the housekeeping stage of the accept loop. > > David Ashley > ooRexx Team > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Oorexx-devel mailing list > Oor...@li... > https://lists.sourceforge.net/lists/listinfo/oorexx-devel > No virus found in this incoming message. > Checked by AVG - http://www.avg.com > Version: 8.0.173 / Virus Database: 270.7.5/1702 - Release Date: 10/6/2008 > 9:23 AM > > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Oorexx-devel mailing list > Oor...@li... > https://lists.sourceforge.net/lists/listinfo/oorexx-devel > > The timeout value is a socket option you can set. In this case it needs to be done prior to the accept call. Here are the two methods to perform this operations depending on if you are using the socket class or not. retc = SockSetSockOpt(s, 'SOL_SOCKET', 'SO_RCVTIMEO', 180) -- 3 minutes or s~setOption('SO_RCVTIMEO', 180) -- 3 minutes Note that if an clent connection is available the accept call will return early. It there is no client available and the timeout expires the accept function returns 62 (ETIME). David Ashley ooRexx Team |