From owner-freebsd-stable@FreeBSD.ORG Fri Oct 7 10:31:55 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 213FF16A41F for ; Fri, 7 Oct 2005 10:31:55 +0000 (GMT) (envelope-from glebius@FreeBSD.org) Received: from cell.sick.ru (cell.sick.ru [217.72.144.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7296D43D46 for ; Fri, 7 Oct 2005 10:31:54 +0000 (GMT) (envelope-from glebius@FreeBSD.org) Received: from cell.sick.ru (glebius@localhost [127.0.0.1]) by cell.sick.ru (8.13.3/8.13.3) with ESMTP id j97AVdhJ039330 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 7 Oct 2005 14:31:40 +0400 (MSD) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.sick.ru (8.13.3/8.13.1/Submit) id j97AVdO6039329; Fri, 7 Oct 2005 14:31:39 +0400 (MSD) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.sick.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Fri, 7 Oct 2005 14:31:38 +0400 From: Gleb Smirnoff To: Lefteris Tsintjelis Message-ID: <20051007103138.GN14542@cell.sick.ru> References: <4345A3DA.1020803@ene.asda.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <4345A3DA.1020803@ene.asda.gr> User-Agent: Mutt/1.5.6i Cc: 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 10:31:55 -0000 Lefteris, On Fri, Oct 07, 2005 at 01:23:22AM +0300, Lefteris Tsintjelis wrote: L> I am trying to set something like this up but it doesn't seem to work L> as I expect it (unless I expect wrong): L> L> timeout.tv_sec = 4; L> timeout.tv_usec = 0; L> if(setsockopt(listenSocket, SOL_SOCKET, SO_RCVTIMEO, (void *)&timeout, L> sizeof(timeout)) == -1) L> fprintf(stdout, "setsockopt SO_RCVTIMEO failed: %s\n", L> strerror(errno)); L> if(setsockopt(listenSocket, SOL_SOCKET, SO_SNDTIMEO, (void *)&timeout, L> sizeof(timeout)) == -1) L> fprintf(stdout, "setsockopt SO_SNDTIMEO failed: %s\n", L> strerror(errno)); L> L> When I telnet to the socket, the socket always stays connected. The L> timer doesn't seem to work right. Am I missing anything here or is L> this broken? You are expecting wrong from these socket options. They do not specify time after which socket should be closed, if no IO is done. The do limit time the process can block on the socket. So, if you do read() from this socket and it blocks, it will resume after 4 seconds even if no input is present. -- Totus tuus, Glebius. GLEBIUS-RIPN GLEB-RIPE