WEBINAR: On-demand webcast
How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >
Have you ever offered an edit control in your application in which the user had to enter an IP address or Hostname?
After the user entered the hostname or IP you have to check what was entered. (IP or hostname???) Then you have to convert the userinput into a proper address for the in_addr structure.
This function is useful for developers who directly access the Winsock API instead of using CAsyncSocket or CSocket. Or, if you wrote your own Socket class and want to offer a connect routine like in CAsyncSocket where you can enter either an IP or Hostname.
The demo project shows how to use GetAddress. It's a simple console based application. The function definition is as follows:
unsigned long GetAddress (const char* p_pHost)
Below are a few examples showing how to use the function:
unsigned long NetworkHostAddress; NetworkHostAddress = GetAddress ("http://www.codeguru.com"); NetworkHostAddress = GetAddress ("126.96.36.199");
DownloadsDownload demo project - 51 Kb
Download source - 2 Kb