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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Map URL address to IP address

Map URL address to IP address

Scheduled Pinned Locked Moved C / C++ / MFC
comquestion
2 Posts 2 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.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    I am not sure if this question makes sense, but I am trying to write program to send email, all the socket functions take IP address as in 155.233.55.10 and not URL address as in www.microsoft.com, wonder if there are functions that map one to the other. Functions I am using are: connect,listen,bind,send,recv. Thanks,

    I 1 Reply Last reply
    0
    • A Anonymous

      I am not sure if this question makes sense, but I am trying to write program to send email, all the socket functions take IP address as in 155.233.55.10 and not URL address as in www.microsoft.com, wonder if there are functions that map one to the other. Functions I am using are: connect,listen,bind,send,recv. Thanks,

      I Offline
      I Offline
      Imran Farooqui
      wrote on last edited by
      #2

      You first need to resolve the URL to corresponding IP address:

      struct hostent * host = gethostbyname(name);

      if ( host == NULL )
      {
      AfxMessageBox("gethostbyname() failed");
      return;
      }

      struct in_addr addr;

      memcpy(&addr, host->h_addr_list[0], sizeof(addr));

      sprintf(m_strHost,"%s", inet_ntoa(addr));

      printf("Resolved Host is %s\n\n",m_strHost);

      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