September 16th, 2015

Why doesn’t GetAddrInfo work from behind a proxy?

A customer was having a problem with the Get­Addr­Info function when running inside a corporate proxy environment.

We are trying to get the IP address of, say, www.microsoft.com by using the Get­Addr­Info function. This works fine if the computer is not behind a proxy, but if it is run in a corporate proxy environment, the call fails with WSAHOST_NOT_FOUND.

The Get­Addr­Info function operates at a level below proxies. When you have a Web proxy, the computer never actually talks to www.microsoft.com directly. Instead, you connect to the proxy and tell the proxy, “Please contact www.microsoft.com for me, thanks.” That’s why it’s called a “proxy”.

You never see the IP address of www.microsoft.com; the only IP address you see is that of the proxy. Besides, since you are inside a corporate proxy environment, even if you had the IP address for www.microsoft.com, it is if no use to you since you cannot connect to it.

There are products that try to smooth over this boundary, so that programs think that they are connected directly to the Internet when in fact they are talking through the proxy.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.