From owner-freebsd-hackers Sun Jul 14 7:50:22 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BF12237B400 for ; Sun, 14 Jul 2002 07:50:12 -0700 (PDT) Received: from search.sparks.net (d-207-5-180-136.gwi.net [207.5.180.136]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6B76943E3B for ; Sun, 14 Jul 2002 07:50:12 -0700 (PDT) (envelope-from dmiller@sparks.net) Received: by search.sparks.net (Postfix, from userid 100) id BC863D992; Sun, 14 Jul 2002 10:49:56 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by search.sparks.net (Postfix) with ESMTP id A9F07D991 for ; Sun, 14 Jul 2002 10:49:56 -0400 (EDT) Date: Sun, 14 Jul 2002 10:49:56 -0400 (EDT) From: David Miller To: hackers@freebsd.org Subject: setsockopt() weirdness Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I'm probably doing something basic wrong, but I'm getting a very inconsistent response when using setsockopt to set the SO_RCVTIMEO to seven seconds or more. The program included works on a 4.3R system, a 4.4R and a 4.6stable system SUPd June 24. The systems are a 486, 800 MHz P-III, and 1.1 GHz t-bird respectively. The program fails to work on a 1 GHz t-bird with 4.6S SUPd last night, and an XP1700+ SUP'd several days ago. "Works" is defined as: bash-2.05$ ./x Successfully set timeout to 6 Successfully set timeout to 7 "Not works" is defined as: alex:c$ ./x Successfully set timeout to 6 Error 33 trying to set socket timeout to 7 Clue greatly appreciated. --- David The program: #include #include #include #include #include #include #include #include extern int errno; main() { int sock, timeout ; struct itimerval s_timeout; if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { printf("Couldn't get a socket, err %d\n",sock); exit(-1); } s_timeout.it_interval.tv_usec = 0; s_timeout.it_value.tv_usec = 0; s_timeout.it_value.tv_sec = 0; s_timeout.it_interval.tv_sec = 6; if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &s_timeout, sizeof(s_timeout))) { printf("Error %d trying to set socket timeout\n",errno); } else { printf("Successfully set timeout to %d\n", s_timeout.it_interval.tv_sec); } s_timeout.it_interval.tv_sec = 7; if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &s_timeout, sizeof(s_timeout))) { printf("Error %d trying to set socket timeout to %d\n", errno, s_timeout.it_interval.tv_sec); } else { printf("Successfully set timeout to %d\n", s_timeout.it_interval.tv_sec); } } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message