Getting the ip address of web sites?

This is a discussion on Getting the ip address of web sites? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Hi, Say i've got a web site address, how do i find out its ip address? thnx...

  1. #1
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020

    Getting the ip address of web sites?

    Hi,

    Say i've got a web site address, how do i find out its ip address?

    thnx

  2. #2
    Banned maes's Avatar
    Join Date
    Aug 2001
    Posts
    744
    try gethostbyname()

    Code:
    WSADATA  wsa;
    struct hostent  *g_hostent;
    struct in_addr MyAddr;
    char IPnumber[100][100];
    
    WSAStartup(MAKEWORD(2,2),&wsa);
    
    g_hostent=gethostbyname("www.cprogramming.com");
    for (i = 0; g_hostent->h_addr_list[i] != 0; ++i)
    		{ //get all IPs
    		SendDlgItemMessage(parglist->hwnd,parglist->idc,WM_SETTEXT,0,(LPARAM)GETIP);
    		memcpy(&MyAddr,g_hostent->h_addr_list[0],sizeof(in_addr)); //You cannot edit the hostent struct
    		strcpy(IPnumber[i],inet_ntoa(MyAddr));//make into IP
    		memset(&MyAddr,0,sizeof(in_addr)); //clean again before next iteration
    		}
    WSACleanup( ); //free winsock resources
    Do not forget to include the wsock32.lib library

    I copy pasted this out of a program of mine, it is possible I fergot something (hope not)


    thx Fordy
    SVG is the future

  3. #3
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    Or if you are talking generally, non programming then simply use ping in dos.

    Do this:

    c:\> ping yahoo.com


    Then in the first line of the reply you will get somthing like this:

    Pinging yahoo.com [216.115.109.7] with 32 bytes of data:

    The IP

    TNT
    TNT
    You Can Stop Me, But You Cant Stop Us All

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Yeah....and if you want it to run it as a single program;

    Code:
    /////////////////////////////
    // Include the WS2_32.lib
    //
    //
    #include <iostream>
    using std::cout;
    using std::cin;
    using std::endl;
    #include <string>
    using std::string;
    #include <winsock2.h>
    
    int main(int argc, char *argv[])
    {
        WSAData wsaData;
    	struct hostent *ptrHE;
    	struct in_addr add;
    	string strHost;
    
        if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
            cout << "Error";
    		return 1;
        }
    
    	cout << "Enter the host name to query" << endl;
    	
    	cin >> strHost;
    
    	ptrHE = gethostbyname(strHost.c_str());
        if (ptrHE == NULL) {
            cout << endl << "Could not find the host." << endl;
            return 1;
        }
    
        for(int i = 0; ptrHE->h_addr_list[i] != 0; ++i) {        
            memcpy(&add, ptrHE->h_addr_list[i], sizeof(struct in_addr));
            cout << endl << "IP Number " << i+1;
    		cout << ": " << inet_ntoa(add) << endl;
        }
    
        WSACleanup();
    
        return 0;
    }

  5. #5
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    its called tracert.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  6. #6
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    Originally posted by no-one
    its called tracert.
    that's gotta be the coolest thing i've seen.... why haven't i found that before now?!?!

  7. #7
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,853
    You haven't been paying attention.

    http://www.telstra.net.au/cgi-bin/trace online tracer
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. IP address network order to string?
    By pobri19 in forum Networking/Device Communication
    Replies: 1
    Last Post: 04-19-2009, 05:15 AM
  2. IP address configuration Files?
    By Matus in forum Tech Board
    Replies: 3
    Last Post: 01-29-2009, 03:35 PM
  3. IP address discovery
    By abinash in forum Networking/Device Communication
    Replies: 6
    Last Post: 04-29-2007, 02:49 PM
  4. Get local IP address
    By Snip in forum Networking/Device Communication
    Replies: 14
    Last Post: 02-28-2005, 02:09 PM
  5. Game Company Web Sites
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-17-2001, 08:32 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21