From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 29 17:56:50 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id A1C94B29; Tue, 29 Jan 2013 17:56:50 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-wg0-f53.google.com (mail-wg0-f53.google.com [74.125.82.53]) by mx1.freebsd.org (Postfix) with ESMTP id 0982FD10; Tue, 29 Jan 2013 17:56:49 +0000 (UTC) Received: by mail-wg0-f53.google.com with SMTP id fn15so487082wgb.8 for ; Tue, 29 Jan 2013 09:56:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=pd7H9vmSNfVaO3FsSl5Hh951BUKzywrvgxJ5qNkhJiY=; b=rJZRbnkRmdVBI+qRNYgSh8LDrqoNALhj/zYFcBLH+2HvKHSLBYTAXTFaA6TqQc1Dio 7uQdjLkXxH6U3e9btr3y8J97wVvaiasBNZv0HACt2Xs7cbOZbJmkaD5oGtXqRXN7aGC7 BUd8Kn1NzR7Azza3wuxPXj3AiQSZ+OV1sJ2lZixiWsxw8FRnyIxV0W07G86JE3rGvC37 E8li5bRFf3U/piZC1hsLiXjHJbkXjl6HvaGEHyz7MpfyA8AUWpD6ztB83Jwk2f+/Tcdn 8biSZ7oUndy1A55f9DwWyDELXGdV5uZEcK9/qfDS/YYcCMWxSH9u9JjyMVY9qa8CchER Kugw== MIME-Version: 1.0 X-Received: by 10.180.82.65 with SMTP id g1mr4224440wiy.22.1359482203045; Tue, 29 Jan 2013 09:56:43 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.216.67.6 with HTTP; Tue, 29 Jan 2013 09:56:42 -0800 (PST) In-Reply-To: <1359481565.93359.160.camel@revolution.hippie.lan> References: <1359385907.93359.84.camel@revolution.hippie.lan> <20130128160238.GT2522@kib.kiev.ua> <1359481565.93359.160.camel@revolution.hippie.lan> Date: Tue, 29 Jan 2013 09:56:42 -0800 X-Google-Sender-Auth: 4bS5EGinOT0RHcxZT0spTw-KZ2I Message-ID: Subject: Re: Sockets programming question From: Adrian Chadd To: Ian Lepore Content-Type: text/plain; charset=ISO-8859-1 Cc: Konstantin Belousov , freebsd-hackers X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jan 2013 17:56:50 -0000 On 29 January 2013 09:46, Ian Lepore wrote: > You can't use EOF on a read() to determine client life when the nature > of the client/server relationship is that clients are allowed to > shutdown(fd, SHUT_WR) as soon as they connect because they expect to > receive but never send any data. > > On the other hand, Alfred's suggestion of using poll(2) rather than > select(2) worked perfectly. Polling with an events mask of zero results > in it returning POLLHUP in revents if the client has closed the socket. Just make sure that's portable.. :-) adrian