From owner-freebsd-net@freebsd.org Mon Apr 17 03:09:27 2017 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 42D24D40051 for ; Mon, 17 Apr 2017 03:09:27 +0000 (UTC) (envelope-from rfg@tristatelogic.com) Received: from outgoing.tristatelogic.com (segfault.tristatelogic.com [69.62.255.118]) by mx1.freebsd.org (Postfix) with ESMTP id 243F5180 for ; Mon, 17 Apr 2017 03:09:26 +0000 (UTC) (envelope-from rfg@tristatelogic.com) Received: from segfault-nmh-helo.tristatelogic.com (localhost [127.0.0.1]) by segfault.tristatelogic.com (Postfix) with ESMTP id 2C5D03AF7B for ; Sun, 16 Apr 2017 20:01:17 -0700 (PDT) From: "Ronald F. Guilmette" To: freebsd-net@freebsd.org Subject: Small socket programming question Date: Sun, 16 Apr 2017 20:01:16 -0700 Message-ID: <83113.1492398076@segfault.tristatelogic.com> X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Apr 2017 03:09:27 -0000 Sorry, I -think- I know that answer to this question, but I'd prefer to ask and make sure, in case I have misunderstood things. I am aware that for any open socket, the kernel sets aside some amount of buffer space for that socket. (And yes, I *do* also know that the specific amount set aside may be programatically controlled.) So anyway, let's say that I have either a RAW or UDP (datagram) socket open and my program is running on a nice fast machine, but it's outbound connection is via a rather slow link. So if my program writes and writes and writes to this socket, eventually, I'll have used up all of the buffer space that the kernel has associated with the socket. My question is just this: What happens then? Will further writes to the socket block until some more packets get sent out, you know, so that there is once again room in the outbound buffer that's associated with this socket? Or will I instead get some error back from the call to write(), like for instance EAGAIN or ENOSPC or maybe ENOBUFS? Or does the kernel in such cases just silently discard one or more of my precious outbound packets without even telling me? (I guess this is my way of asking whether or not the FreeBSD kernel may, in some cases, itself be a source of "packet loss".) Thanks in advance for any & all enlightening replies.