Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Function sf::IpAddress::getLocalAddress() on MacOS  (Read 8625 times)

0 Members and 1 Guest are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Function sf::IpAddress::getLocalAddress() on MacOS
« Reply #15 on: October 02, 2013, 09:01:30 am »
You should also zero the whole structure in the Windows implementation, for consistency.

I just tested using port 9 on Windows 8 and it works.
Laurent Gomila - SFML developer

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Function sf::IpAddress::getLocalAddress() on MacOS
« Reply #16 on: October 02, 2013, 09:17:54 am »
I just checked again, and the reason why this method is possible on Linux (and probably other Unix's & OS X) is because you don't bind a port < 1024. If you just try to connect a socket (TCP or UDP) to local host, it bypasses all port checks because the source port will be in the ephemeral range. This is why you can request a web page from the local host (running on port 80) without your browser requiring any extra privileges.

I don't know how you came to the conclusion that low port numbers don't work on OS X, but it can't have been a permission issue. Port 0 is probably invalid because of its special status.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Function sf::IpAddress::getLocalAddress() on MacOS
« Reply #17 on: October 02, 2013, 10:36:36 am »
You should also zero the whole structure in the Windows implementation, for consistency.

I just tested using port 9 on Windows 8 and it works.

Indeed. Will do.

I don't know how you came to the conclusion that low port numbers don't work on OS X, but it can't have been a permission issue. Port 0 is probably invalid because of its special status.
I've found this SO where James says «Only root has privileges for ports below 1024». He doesn't give any reference, though. However, this seems to be true: I use MAMP to run a local Apache server on my machine. When I set Apache to use port 80 I need to give my credentials. But with a port like 8888 I don't need. It's not a proof but still.
SFML / OS X developer