How to get server ip on server side

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

ganquan
Posts: 38
Joined: 17 Apr 2013, 01:42

How to get server ip on server side

Postby ganquan » 21 Jul 2015, 14:53

Hi
how to get the server ip and port in room extension?
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to get server ip on server side

Postby Lapo » 21 Jul 2015, 19:05

It depends, what you need is the private IP address.
By default SFS2X 2.9 and higher bind the 0.0.0.0 address, which means "bind whatever is available".

With that setup you won't know exactly which address is the private one because your server may have more network interfaces... or it may not :)

If you bind the address manually from the AdminTool you could then read the address and port from runtime:

Code: Select all

List<SocketAddress>  addresses  = SmartFoxServer.getConfigurator().getServerSettings().socketAddresses;
SocketAddress addr = addresses.get(0);


cheers
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 127 guests