IP without connecting to external socket

This is a discussion on IP without connecting to external socket within the Networking/Device Communication forums, part of the General Programming Boards category; Hey guys, I've been searching the boards, FAQ, and more boards for this, but I haven't found a solution yet. ...

  1. #1
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879

    Arrow IP without connecting to external socket

    Hey guys, I've been searching the boards, FAQ, and more boards for this, but I haven't found a solution yet. Basically, I'm trying to find my IP address; I've read all about these 2 methods:
    a:
    gethostname()
    gethostbyname()

    b:
    getsockname()

    Problem with a: gethostname() gives me "kevin", and using gethostbyname() gives me my LAN address (the one assigned to me by my router).

    Problem with b: I'm trying to get my IP address so that I can display it to the user and the user can then tell other users the IP so that other users can connect to the server; if other users already know the IP and can connect to the server so that I can get the IP address, the whole thing is pointless.

    So my question is, is there any way to get my external IP address without having to connect to an external client?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    No.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    ... ok, thanks...
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  4. #4
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Shoot, I tried just connecting to www.google.ca and doing getsockname(), and I still ended up with my 192.168.a.b address. Since I'm behind a router, do I HAVE to do the connect-to-ip-broadcasting-website approach, or is there any other way?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  5. #5
    Wen Resu
    Join Date
    May 2003
    Posts
    219
    because your behind a router, you IP is 192.168.a.b
    what you could do is have the server detect the IP of the connection, and that would be your user who is loggin in's IP.

  6. #6
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Thanks, but... could you explain what you mean? From what I gather, you're saying that I can connect to a user and the user can find my IP and send it back or something... but I'm trying to get the IP before connecting.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 01:13 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 03:01 PM

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