From owner-freebsd-net Thu May 10 9:37:45 2001 Delivered-To: freebsd-net@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id 55BA637B424 for ; Thu, 10 May 2001 09:37:42 -0700 (PDT) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.9.3/8.9.3) id MAA81740; Thu, 10 May 2001 12:37:39 -0400 (EDT) (envelope-from wollman) Date: Thu, 10 May 2001 12:37:39 -0400 (EDT) From: Garrett Wollman Message-Id: <200105101637.MAA81740@khavrinen.lcs.mit.edu> To: Alfred Perlstein Cc: net@FreeBSD.ORG Subject: Re: getaddrinfo irritation In-Reply-To: <20010510092401.M18676@fw.wintelcom.net> References: <20010510082025.J18676@fw.wintelcom.net> <200105101540.LAA81367@khavrinen.lcs.mit.edu> <20010510090322.K18676@fw.wintelcom.net> <20010510090907.L18676@fw.wintelcom.net> <200105101612.MAA81594@khavrinen.lcs.mit.edu> <20010510092401.M18676@fw.wintelcom.net> Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org < said: > I guess this is a no-no then? It tries to match the protocol with > the socktype. Well, the specification appears to leave this possibility open. It says: # A value of zero for ai_socktype means that the caller shall accept # any socket type. So it is not illegitimate for the library to say ``OK, he wants protocol 6, so let's pick a socket type that we know has a protocol 6''; the application has already indicated that it doesn't care. However, I would argue that any application that thinks it doesn't care is broken. So much of the API depends on whether the application is using a connection-oriented or connectionless model that it is difficult to conceive of any non-trivial application that didn't care what sort of socket type it received. So, I would suggest that the correct solution for your program is instead: if (strcmp(protocol, "tcp") == 0) hint.ai_socktype = SOCK_STREAM; else hint.ai_socktype = SOCK_DGRAM; ...or even better, require the user to specify which model it was using. (Again, most programs only make sense for one or the other.) -GAWollman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message