Re: [BEHAVE] (no subject)

ivan c <ivan@cacaoweb.org> Thu, 27 June 2013 22:12 UTC

Return-Path: <ivan@cacaoweb.org>
X-Original-To: behave@ietfa.amsl.com
Delivered-To: behave@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id CE7CB21F8C66 for <behave@ietfa.amsl.com>; Thu, 27 Jun 2013 15:12:50 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.3
X-Spam-Level:
X-Spam-Status: No, score=-1.3 tagged_above=-999 required=5 tests=[AWL=1.300, BAYES_00=-2.599]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gFqddwgDyhK7 for <behave@ietfa.amsl.com>; Thu, 27 Jun 2013 15:12:45 -0700 (PDT)
Received: from mail.cacaoweb.org (mail.cacaoweb.org [46.105.102.78]) by ietfa.amsl.com (Postfix) with ESMTP id A416121F9A50 for <behave@ietf.org>; Thu, 27 Jun 2013 15:12:45 -0700 (PDT)
Received: from www-data by mail.cacaoweb.org with local (Exim 4.72) (envelope-from <ivan@cacaoweb.org>) id 1UsKRk-0006Jw-Q3; Fri, 28 Jun 2013 00:13:44 +0200
To: Simon Perreault <simon.perreault@viagenie.ca>
X-PHP-Originating-Script: 0:func.inc
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
Date: Fri, 28 Jun 2013 00:13:44 +0200
From: ivan c <ivan@cacaoweb.org>
Organization: cacaoweb
In-Reply-To: <51CC2ED4.7090506@viagenie.ca>
References: <CB1B483277FEC94E9B58357040EE5D02325A6E93@xmb-rcd-x15.cisco.com> <2f7dce8264c8a9a72640629502a44295@cacaoweb.org> <51C1681A.5030909@viagenie.ca> <f8741fad1af1cee094de9c59408b7425@cacaoweb.org> <51C40374.8080403@viagenie.ca> <21e25b7ae1501228a67656b2fa4bc009@cacaoweb.org> <51CAA20F.4070307@viagenie.ca> <88c0ada2b8ebad078fb249ac6572fd8b@cacaoweb.org> <51CBD188.4060408@viagenie.ca> <fc3c7389e9fc7afc9201f0516de436a7@cacaoweb.org> <51CC2ED4.7090506@viagenie.ca>
Message-ID: <8335eb535d5b47319b8c804c65490ecb@cacaoweb.org>
X-Sender: ivan@cacaoweb.org
User-Agent: RoundCube Webmail/0.3.1
Cc: behave@ietf.org
Subject: Re: [BEHAVE] (no subject)
X-BeenThere: behave@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
Reply-To: ivan@cacaoweb.org
List-Id: mailing list of BEHAVE IETF WG <behave.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/behave>, <mailto:behave-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/behave>
List-Post: <mailto:behave@ietf.org>
List-Help: <mailto:behave-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/behave>, <mailto:behave-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 27 Jun 2013 22:12:50 -0000

On Thu, 27 Jun 2013 14:23:48 +0200, Simon Perreault
<simon.perreault@viagenie.ca> wrote:
> 
> connect()ing UDP sockets has two big advantages:
> 
> 1) It allows using the same programming model for UDP and TCP. More code

> can be factored out, which is good software engineering.

Usually applications use UDP and TCP differently and for different things,
but that's an interesting point.


> 2) It propagates ICMP errors up through the BSD API, allowing 
> straightforward error handling that is again similar to TCP and can be 
> factored out. For non-connected UDP sockets, ICMP errors are simply
> ignored.

All errors (including ICMP) are received for all UDP sockets.
If you call select() on your sockets, the sockets with the errors will be
select()-ed, and the subsequent recvfrom() call will return the error code.
An ICMP message will trigger a ECONNRESET error I think.


> Since file descriptors are basically free, come at no additional 
> performance cost when you use something like epoll, kqueue, or windows 
> IOCP, and since this method does not consume additional ports, I 
> recommend it over sendto()/recvfrom() when I teach network programming.
> 
> This comes from W. Richard Stevens "UNIX Network Programming". The 
> technique is used a lot in the wild. I'm not inventing anything.


-- 
_Ivan Chollet_