On Tue, May 5, 2009 at 9:23 AM, David Turner <di...@android.com> wrote: > ok, I reproduced the issue and isolated it in the getaddrinfo() > implementation (which comes straight from BSD). > Technically, this is not a bug because POSIX states that: > > If hints is a null pointer, the behavior shall be as if it referred to a > structure containing the value zero for > the ai_flags, ai_socktype, and ai_protocol fields, and AF_UNSPEC for the > ai_family field. > > the key thing here is that ai_socktype will be set to 0, which on Linux > doesn't correspond to any of SOCK_RAW, > SOCK_STREAM or SOCK_DGRAM; and the getaddrinfo() implementation will reject > any numerical value passed > in the "servicename" parameter except for SOCK_STREAM or SOCK_DGRAM. > > I checked the latest OpenBSD sources and they seem the belong exactly like > that too, which probably means that > your code is not, technically speaking, portable. > > This is however probably annoying and I will modify the code for the next > platform release. > In the meantime, just use a hint :-)
Ok, thanks for your help! > On Sat, May 2, 2009 at 7:41 PM, David Turner <di...@android.com> wrote: >> >> Hello, >> >> this certainly looks like a bug, I will take a look at it. In the >> meantime, please use a hint to work-around it. >> Regards >> >> On Sat, May 2, 2009 at 7:19 PM, Carlos A. M. dos Santos ---8<-- >>> I just realized that I pasted too many lines. The presence of the >>> "hints" variable in the code above became misleading. It is important >>> to point out that the error does not happen if I pass the hints to >>> getaddrinfo, like this: >>> >>> struct addrinfo hints; >>> struct addrinfo *addi; >>> ::memset(&hints, 0, sizeof(hints)); >>> hints.ai_family = AF_UNSPEC; >>> hints.ai_socktype = SOCK_STREAM; >>> hints.ai_protocol = IPPROTO_TCP; >>> int status = ::getaddrinfo(hostname, "9999", &hints, &addi); >>> >>> I'm intrigued about the different behaviors of Linux and Android when >>> the hint parameter is NULL. Which one is correct? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "android-framework" group. To post to this group, send email to android-framework@googlegroups.com To unsubscribe from this group, send email to android-framework+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-framework?hl=en -~----------~----~----~----~------~----~------~--~---