From owner-freebsd-hackers@FreeBSD.ORG Tue Feb 10 11:11:31 2004 Return-Path: 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 E6C5B16A4CE for ; Tue, 10 Feb 2004 11:11:31 -0800 (PST) Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) by mx1.FreeBSD.org (Postfix) with ESMTP id ACDC243D1D for ; Tue, 10 Feb 2004 11:11:31 -0800 (PST) (envelope-from julian@elischer.org) Received: from interjet.elischer.org ([24.7.73.28]) by comcast.net (sccrmhc13) with ESMTP id <2004021019112901600f9tc6e>; Tue, 10 Feb 2004 19:11:30 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id LAA82965; Tue, 10 Feb 2004 11:11:28 -0800 (PST) Date: Tue, 10 Feb 2004 11:11:27 -0800 (PST) From: Julian Elischer To: Andrew In-Reply-To: <20040210100257.G56192-100000@starbug.ugh.net.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-hackers@freebsd.org Subject: Re: select, sendto and ENOBUFS X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Feb 2004 19:11:32 -0000 On Tue, 10 Feb 2004, Andrew wrote: > Hi, > > I have a problem with sendto returning an error and setting errno to > ENOBUFS however I am calling select first to make sure the fd is > writeable (see below for code). s is a raw socket and the data I'm > sending is 1492 bytes. I haven't changed the low water mark for the > socket. > > This looks like a bug however the bug may well be mine... > > Does anyone have any ideas? > > Thanks, This is not a bug select says "yes there is room inm the socket buffer" however datagram protocols do not store anythign in the outgoing socket buffer, but, instead hand the packets directly to the driver for the NIC. when the NIC fils up it returns ENOBUFS this is your cue to do a usleep(1000) before sending more packets. > > Andrew > > do { > printf("waiting on socket\n"); > FD_ZERO(&fdset); > FD_SET(s, &fdset); > if (select(s + 1, NULL, &fdset, NULL, NULL) == -1) { > warn("select"); > return 0; > } > } while (! FD_ISSET(s, &fdset)); > printf("socket ready\n"); > > if (se$ndto(s, (void *)ip_packet, ip_packet->ip_len, 0, (struct sockaddr > *)&sa, sizeof(sa)) == -1) { > if (errno == ENOBUFS) { > warn("sleeping 1 second - sendto"); > sleep(1); > } else { > warn("sendto"); > } > return 0; > } > > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >