Posted on 1999-10-06
Medium Priority
Last Modified: 2013-11-20
I have the name of a machine in our network, how to get the IP address of that machine.
Question by:Mohammed_maridi
1 Comment

Accepted Solution

V_Bapat earned 20 total points
ID: 2102728
Use this function to get the ipaddress whether you provide the machine name or IP Address as a string format:

u_long CTelnetDlg::GetAddr(LPSTR szHost)
      LPHOSTENT lpstHost;
      u_long lAddr = INADDR_ANY;
      /* check that we have a string */
      if (*szHost)
            /* check for a dotted-IP address string */
            lAddr = inet_addr (szHost);
            /* If not an address, then try to resolve it as a hostname */
            if ((lAddr == INADDR_NONE) && (strcmp (szHost, "")))
                  lpstHost = gethostbyname(szHost);
                  if (lpstHost)
                  { /* success */
                        lAddr = *((u_long FAR *) (lpstHost->h_addr));
                  { /* failure */
                        lAddr = INADDR_ANY;  
      return (lAddr);


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
If you are looking for an automated tool which can generate reports for Outlook emails and other items from PST file, then you can go for Kernel PST Reporter tool. The reports which are created by this tool are helpful to analyze and understand PST …

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question