SFML community forums

Help => Network => Topic started by: Grimshaw on September 03, 2011, 12:11:02 am

Title: GetLocalAddress doesnt seem correct
Post by: Grimshaw on September 03, 2011, 12:11:02 am
When i do this:

sf::IpAddress::GetLocalAddress().ToString();

I get 127.0.0.1, i was expecting my LAN address 192.168.10.2.

Any other way to get it?

Thanks
Title: Re: GetLocalAddress doesnt seem correct
Post by: Haikarainen on September 03, 2011, 07:08:14 am
Quote from: "DevilWithin"
When i do this:

sf::IpAddress::GetLocalAddress().ToString();

I get 127.0.0.1, i was expecting my LAN address 192.168.10.2.

Any other way to get it?

Thanks


Thats weird, you should think IpAdress::LocalHost would be 127.0.0.1.. SFML Network doesn't seem to be able to list assigned ipadresses either, maybe we should post this feat on the bugtracker :p

for now i found this: http://www.codeguru.com/forum/showthread.php?t=233261
Title: GetLocalAddress doesnt seem correct
Post by: Laurent on September 03, 2011, 09:53:30 am
Handling multiple network interfaces in SFML is planned for the future.

I don't know why you get localhost instead of your local network address, but maybe it's related to this issue:
https://github.com/SFML/SFML/issues/47

What's your OS?
Title: GetLocalAddress doesnt seem correct
Post by: Grimshaw on September 03, 2011, 01:22:57 pm
Windows 7 32bit !

I have a really simple ISP service through ADSL. I own a DLink wireless router, to which the laptops in my house connect. My computer connects directly via RJ-45 cable.

My computer and the laptops work fine as a LAN, even allowing file sharing etc.

Thanks
Title: GetLocalAddress doesnt seem correct
Post by: Haikarainen on September 04, 2011, 09:12:29 am
Hm, I tried this out and found out I also get 127.0.0.1 ! :S

Code: [Select]
std::cout << "Local address: " << sf::IpAddress::GetLocalAddress().ToString().c_str() << "\n";
std::cout << "Public address: " << sf::IpAddress::GetPublicAddress().ToString().c_str() << "\n";


Gives;
Quote
Local address: 127.0.0.1
Public address: 81.170.129.***


OS: Windows XPSP3 w/ latest updates
SFML: old unstable of 2.0
Network: RJ45 -> Router(D-Link DIR 615) -> Fibreconverter

Local addresses;
192.168.0.100 - Network
192.168.56.1 - Virtualbox Hostonly

Doesnt matter if i disable virtualbox adapter
Title: GetLocalAddress doesnt seem correct
Post by: Laurent on September 04, 2011, 09:39:52 am
I can reproduce the bug too. It seems that is was broken with some revision a few months ago; so at least I should be able to fix it easily :)

Thanks for your feedback.
Title: GetLocalAddress doesnt seem correct
Post by: Grimshaw on September 04, 2011, 01:59:55 pm
When its fixed please warn us Laurent, and thanks a lot for all the support. You re the man :)
Title: GetLocalAddress doesnt seem correct
Post by: Laurent on September 04, 2011, 02:46:08 pm
It's fixed.