- if( p_hints == NULL )
- memset( &hints, 0, sizeof( hints ) );
- else
- memcpy( &hints, p_hints, sizeof( hints ) );
+ memset (&hints, 0, sizeof (hints));
+ if (p_hints != NULL)
+ {
+ hints.ai_family = p_hints->ai_family;
+ hints.ai_socktype = p_hints->ai_socktype;
+ hints.ai_protocol = p_hints->ai_protocol;
+ hints.ai_flags = p_hints->ai_flags & (AI_NUMERICHOST|AI_PASSIVE|AI_CANONNAME);
+ }
+#ifdef AI_NUMERICSERV
+ /* we only ever use port *numbers* */
+ hints.ai_flags |= AI_NUMERICSERV;
+#endif