From owner-freebsd-stable@FreeBSD.ORG Fri Oct 7 15:31:21 2005 Return-Path: X-Original-To: freebsd-stable@FreeBSD.org Delivered-To: freebsd-stable@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 881B016A41F; Fri, 7 Oct 2005 15:31:21 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from vms048pub.verizon.net (vms048pub.verizon.net [206.46.252.48]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3F59043D48; Fri, 7 Oct 2005 15:31:21 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from [192.168.1.3] ([68.161.71.31]) by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0INZ00LLIXS8B340@vms048.mailsrvcs.net>; Fri, 07 Oct 2005 10:31:20 -0500 (CDT) Date: Fri, 07 Oct 2005 11:31:22 -0400 From: Chuck Swiger In-reply-to: <20051007140744.GC14542@cell.sick.ru> To: Gleb Smirnoff Message-id: <434694CA.2060500@mac.com> Organization: The Courts of Chaos MIME-version: 1.0 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7bit X-Accept-Language: en-us, en References: <4345A3DA.1020803@ene.asda.gr> <20051007103138.GN14542@cell.sick.ru> <43468078.1000201@ene.asda.gr> <20051007140744.GC14542@cell.sick.ru> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Cc: Lefteris Tsintjelis , freebsd-stable@FreeBSD.org Subject: Re: setsockopt and SO_RCV/SNDTIMEO X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Oct 2005 15:31:21 -0000 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