This is a new implementation according to your comments.<br><br>Here is my comments to this patch<br><br>1. ngx_inet_sock_addr is removed. You are right, ngx_parse_url can do that job. So no need to change ngx_inet.h<br><br>

2. the old &quot;gethostbyname&quot; implementation will be used if &quot;--with-ipv6&quot; is not set; when &quot;--with-ipv6&quot; is set, &quot;getaddrinfo&quot; will be used<br><br>3. now when &quot;ngx_inet_parse_url&quot; find u-&gt;host might be a hostname, it will invoke new added function &quot;ngx_inet_resolve_hostname&quot;.<br>

<br>4. seems there is a bug in old file&#39;s line 829. Only when uri is NULL, len = last - port.<br><br>5. now &quot;ngx_inet6_parse_url&quot; will finally invoke new added &quot;ngx_inet6_resolve_host&quot;, just like what &quot;ngx_inet_parse_url&quot; does. I think it should be done but the old code doesn&#39;t do that. Please confirm this is valid.<br>

<br>6. I try to remove duplicated code as much as possible, so the &quot;ngx_inet_resolve_host&quot; is almost rewritten. Now, it will first handle the u-&gt;host as it&#39;s an IP; if not, it will try to resolve them.<br>

<br>7. In &quot;ngx_inet_parse_url&quot;, it firstly assume it&#39;s AF_INET and allocate the memory. I think it&#39;s not suitable in the new implementation, but I didn&#39;t touch this part of code.<br><br>8. All the fix are tested as before (with and without &quot;--with-ipv6&quot;), all test are passed.<br>

<br>9. I make this implementation based on 0.9.3. I compare the ngx_inet.c in official 0.9.3 and 0.9.5, and find there is a difference:<br><br>-        for (i = 0; i &lt; u-&gt;naddrs; i++) {<br>+        for (i = 0; h-&gt;h_addr_list[i] != NULL; i++) {<br>

<br>Since my implementation use &quot;getaddrinfo&quot;, h_addr_list[i] will be invalid when &quot;--with-ipv6&quot; is set.<br><br>Thanks.<br><br>