From owner-freebsd-questions Fri Jan 10 19:43:44 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id TAA24350 for questions-outgoing; Fri, 10 Jan 1997 19:43:44 -0800 (PST) Received: from mailgate ([202.159.65.166]) by freefall.freebsd.org (8.8.4/8.8.4) with SMTP id TAA24338; Fri, 10 Jan 1997 19:43:25 -0800 (PST) Received: from bandung.wasantara.net.id (bandung.wasantara.net.id [202.159.69.35]) by mailgate (8.6.11/8.6.9) with ESMTP id KAA00164; Sat, 11 Jan 1997 10:28:57 +0700 Date: Sat, 11 Jan 1997 10:28:57 +0700 Received: from BANDUNG/SpoolDir by bandung.wasantara.net.id (Mercury 1.21); 11 Jan 97 11:35:15 GMT+0700 Received: from SpoolDir by BANDUNG (Mercury 1.21); 11 Jan 97 11:34:34 GMT+0700 Received: from shuttle.wasantara.net.id by bandung.wasantara.net.id (Mercury 1.21); 11 Jan 97 11:34:25 GMT+0700 X-Sender: eka@werty.wasantara.net.id (Unverified) X-Mailer: Windows Eudora Pro Version 2.1.2 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: freebsd-hackers@freebsd.org From: Eka Kelana Subject: bug in setsockopt()... ? Cc: freebsd-questions@freebsd.org Message-ID: <1CA927E5D71@bandung.wasantara.net.id> Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Hi, I wonder if there is anyone here ever experience a bug in setsockopt(). I did this when I found the bug: ...skipped if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) err("socket"); mes("socket"); #if defined(SO_SNDBUF) || defined(SO_RCVBUF) if (sockbufsize) { if (trans) { if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*) &sockbufsize,sizeof(sockbufsize)) < 0) err("setsockopt: sndbuf"); mes("sndbuf"); } else { if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &sockbufsize, sizeof sockbufsize) < 0) err("setsockopt: rcvbuf"); mes("rcvbuf"); } } #endif ...skipped optlen = sizeof(sockbufsize); if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, &optlen) < 0) err("getsockopt"); printf("socket send buff before connect: %d\n", sockbufsize); if(connect(fd, &sinhim, sizeof(sinhim) ) < 0) err("connect"); mes("connect"); optlen = sizeof(sockbufsize); if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, &optlen) < 0) err("getsockopt"); printf("socket buff size after connect: %d\n", sockbufsize); The two getsockopt() above produced different value of socket buffer size. When I didn't try to change the socket buffer size and used the default value instead, the first getsockopt() would produce 16384 bytes. I think this is the correct value, since FreeBSD set the default value for socket buffer size to 16384 bytes. But the second getsockopt() would produce 17280 bytes. I couldn't find any reasonable explanation of this behaviour, but I think it is a bug in FreeBSD networking code. I even couldn't set the socket buffer size to another value. It still shows 17280 bytes. And another crosscheck using tcpdump still shows a receive window of 17280 which means that the receive buffer is set to 17280. I need a reasonable explanation around this problem. Is there anyone here who is able to give such explanation to me ? -Eka Kelana- STTTelkom