locked
How to determin my IP using winsock2 ? RRS feed

  • Question

  • Hey all, I"m building a c++ console app using VS.2005 and I use winsock2.h for network programming.

    How do i determin my own IP address?

     

    Thanks in advance :D

    Monday, October 16, 2006 5:58 PM

Answers

  • Actually, you have more than one address (if you include routable and non-routable IPs). Take a look at GetAdaptersInfo() API.
    Monday, October 16, 2006 6:24 PM

All replies

  • Actually, you have more than one address (if you include routable and non-routable IPs). Take a look at GetAdaptersInfo() API.
    Monday, October 16, 2006 6:24 PM
  • Which files or libraries do I have to include inorder to use this function?
    Monday, October 16, 2006 7:13 PM
  • for that answer you can easily check it from your document explorer, for every function MS Documentation provides the Library that the function is implemented and what includes you need to add in order to make use of it. It also provides requirement info (such as O.S. Support and other noteworthy issues)

    find it for yourself ;), it's very useful- especially if you are developing for hours

     

    for the function you requested the Req's are:

     

      Client Requires Windows XP, Windows 2000 Professional, Windows Me, or Windows 98.
       Server Requires Windows Server 2003 or Windows 2000 Server.
         Header

    Declared in Iphlpapi.h.

         Library

    Link to Iphlpapi.lib.

    DLL

    Requires Iphlpapi.dll.

    and the URL for your local machine would be ms-help://MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.WIN32COM.v10.en/iphlp/iphlp/getadaptersinfo.htm

     

    if you need anything else post ;)

    Monday, October 16, 2006 8:32 PM
  • For future reference, network related questions should be asked here.  Please reserve this forum for C++ language questions, as the title of the forum states.
    Tuesday, October 17, 2006 3:33 AM
  •  spree wrote:
    Which files or libraries do I have to include inorder to use this function?

    Isn't that the sole purpose of MSDN?

    Tuesday, October 17, 2006 7:03 AM
  • Thanks :)
    Tuesday, October 17, 2006 1:02 PM