Date: Thu, 10 May 2001 12:37:39 -0400 (EDT) From: Garrett Wollman <wollman@khavrinen.lcs.mit.edu> To: Alfred Perlstein <bright@wintelcom.net> Cc: net@FreeBSD.ORG Subject: Re: getaddrinfo irritation Message-ID: <200105101637.MAA81740@khavrinen.lcs.mit.edu> 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>
next in thread | previous in thread | raw e-mail | index | archive | help
<<On Thu, 10 May 2001 09:24:01 -0700, Alfred Perlstein <bright@wintelcom.net> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200105101637.MAA81740>