Date: Fri, 07 Oct 2005 11:31:22 -0400 From: Chuck Swiger <cswiger@mac.com> To: Gleb Smirnoff <glebius@FreeBSD.org> Cc: Lefteris Tsintjelis <lefty@ene.asda.gr>, freebsd-stable@FreeBSD.org Subject: Re: setsockopt and SO_RCV/SNDTIMEO Message-ID: <434694CA.2060500@mac.com> In-Reply-To: <20051007140744.GC14542@cell.sick.ru> References: <4345A3DA.1020803@ene.asda.gr> <20051007103138.GN14542@cell.sick.ru> <43468078.1000201@ene.asda.gr> <20051007140744.GC14542@cell.sick.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
Gleb Smirnoff wrote: > On Fri, Oct 07, 2005 at 05:04:40PM +0300, Lefteris Tsintjelis wrote: > L> >You are expecting wrong from these socket options. They do not specify > L> >time after which socket should be closed, if no IO is done. > L> > L> Is there any easy build in functionality for that? > > Pardon, but I do not understand the question. He wants the connection to be closed after a certain number of seconds if it is idle. Lefterius, when you read() from the socket, call time(). If you read more than zero bytes, save that time in a variable. If you read zero bytes, compare what time it is now to the saved value, and if the delta is greater than when you want an idle connection to close, well, call close() and exit or whatever. Details like initializing the variable to now beforehand are probably needed. -- -Chuck
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?434694CA.2060500>