Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. dsn to ip in c++

dsn to ip in c++

Scheduled Pinned Locked Moved C / C++ / MFC
c++com
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Irish_GUI
    wrote on last edited by
    #1

    i want to allow a user to enter a website address (eg. www.microsoft.com) into a text box and i can then resolve this address to its IP address. i am sure there is a function for this, but i cannot find it thanks

    O A 2 Replies Last reply
    0
    • I Irish_GUI

      i want to allow a user to enter a website address (eg. www.microsoft.com) into a text box and i can then resolve this address to its IP address. i am sure there is a function for this, but i cannot find it thanks

      O Offline
      O Offline
      Orkun GEDiK
      wrote on last edited by
      #2

      Hi, You can use "accept(hSocket,(struct sockaddr*)&stcSockaddrCln,&iSocketSize)" in order to accept incoming request. If you want to resolve dns to ip number, you may use "inet_ntoa(stcSockaddrCln.sin_addr)". I hope it's good enough for you. Regards, Orkun Gedik Ahmet Orkun GEDiK System & Software Support Specialist (SAP R/3) ASTRON

      1 Reply Last reply
      0
      • I Irish_GUI

        i want to allow a user to enter a website address (eg. www.microsoft.com) into a text box and i can then resolve this address to its IP address. i am sure there is a function for this, but i cannot find it thanks

        A Offline
        A Offline
        avenger_sb25
        wrote on last edited by
        #3

        This function is the one you r looking for----> gethostbyname The Windows Sockets gethostbyname function retrieves host information corresponding to a host name from a host database. struct hostent FAR *gethostbyname( const char FAR *name ); Parameters name [out] Pointer to the null-terminated name of the host to resolve. Return Values If no error occurs, gethostbyname returns a pointer to the HOSTENT structure described above. Otherwise, it returns a NULL pointer and a specific error number can be retrieved by calling WSAGetLastError. Error code Meaning WSANOTINITIALISED A successful WSAStartup call must occur before using this function. WSAENETDOWN The network subsystem has failed. WSAHOST_NOT_FOUND Authoritative answer host not found. WSATRY_AGAIN Nonauthoritative host not found, or server failure. WSANO_RECOVERY A nonrecoverable error occurred. WSANO_DATA Valid name, no data record of requested type. WSAEINPROGRESS A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function. WSAEFAULT The name parameter is not a valid part of the user address space. WSAEINTR A blocking Windows Socket 1.1 call was canceled through WSACancelBlockingCall. Remarks The gethostbyname function returns a pointer to a HOSTENT structure—a structure allocated by Windows Sockets. The HOSTENT structure contains the results of a successful search for the host specified in the name parameter. The application must never attempt to modify this structure or to free any of its components. Furthermore, only one copy of this structure is allocated per thread, so the application should copy any information it needs before issuing any other Windows Sockets function calls. The gethostbyname function cannot resolve IP address strings passed to it. Such a request is treated exactly as if an unknown host name were passed. Use inet_addr to convert an IP address string the string to an actual IP address, then use another function, gethostbyaddr, to obtain the contents of the HOSTENT structure. The gethostbyname function resolves the string returned by a successful call to gethostname. Requirements Version: Requires Windows Sockets 1.1 or later. Header: Declared in Winsock2.h. Library: Use Ws2_32.lib.


        Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups