get server IP in java extension

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

User avatar
zood
Posts: 21
Joined: 02 Jul 2007, 17:29
Location: San Francisco
Contact:

get server IP in java extension

Postby zood » 09 Aug 2007, 16:52

Hi there,

Is there a way to get the smartfoxserver's IP address in a server-side java extension? I have a case where I need to use the server's IP address and I would prefer not to hard-code it.

Alternatively, is it possible to make smartfoxserver listen on more than one address, i.e. loopback and public IP?

thanks!
-zood
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 10 Aug 2007, 17:30

IP address can be read with:

Code: Select all

String ip = SmartFoxServer.SERVER_ADDR

This will reflect the setting in the config.xml

Alternatively, is it possible to make smartfoxserver listen on more than one address, i.e. loopback and public IP?

Yep, with the latest patch ( 1.5.8 ) SFS binds to both the physical and loopback addresses

cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
August04
Posts: 7
Joined: 17 Aug 2007, 17:44
Location: Canada

Postby August04 » 08 Jan 2008, 03:49

IP address can be read with:

Code: Select all

String ip = SmartFoxServer.SERVER_ADDR


Hi Lapo,

The above does not work with SmartFox 1.6.0. What will be the right way to get server IP and port number using version 1.6.0? Thank you.


[/quote]
rsnail
Posts: 33
Joined: 04 Nov 2005, 20:19

Postby rsnail » 08 Jan 2008, 17:52

Same problem. Unable to get the following to work in 1.6

String ipAddr = SmartFoxServer.SERVER_ADDR;
int port = SmartFoxServer.SERVER_PORT;

Thanks
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 08 Jan 2008, 19:01

Many of the static settings were moved to a Configuration class in version 1.6
I apologize for not giving any notice about this, we didn't think that those values would be accessed by extension code.

The fully qualified name of the class is called it.gotoandplay.smartfoxserver.config.ConfigData

You can read those two properties like this:

Code: Select all

import it.gotoandplay.smartfoxserver.config.ConfigData;
...
...
String ipAddr = ConfigData.SERVER_ADDR;
int port = ConfigData.SERVER_PORT;
Lapo

--

gotoAndPlay()

...addicted to flash games
nitish5221
Posts: 6
Joined: 10 Apr 2020, 11:30

Re: get server IP in java extension

Postby nitish5221 » 14 May 2020, 13:55

Is there a way to get the smartfoxserver's IP address in a server-side java extension
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: get server IP in java extension

Postby Lapo » 14 May 2020, 15:39

nitish5221 wrote:Is there a way to get the smartfoxserver's IP address in a server-side java extension

I’d recommend this article:
https://stackoverflow.com/questions/293 ... ss-in-java

see the first solution proposed.
Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 21 guests