Subject: Re: does getaddrinfo() behave correctly?
To: None <>
From: Michael van Elst <>
List: tech-userlevel
Date: 09/15/2007 23:46:45 (Klaus Heinz) writes:

>in the course of building a package I discovered this (IMO) strange
>behaviour of getaddrinfo() concerning port numbers:

>This does not:
>  $ ./test-getaddrinfo localhost 25  
>  result: 9 = servname not supported for ai_socktype

There is no way for getaddrinfo() to deduce a protocol
from just a port number.

Giving it a hint that you want data for a SOCK_STREAM is
enough and you get:

result: 0 = Success
flags: 0, family: 24, socktype: 1, protocol: 6

                                Michael van Elst
                                "A potential Snark may lurk in every tree."