aboutsummaryrefslogtreecommitdiff
path: root/backends/networking/sdl_net
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-05 17:52:29 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commiteae57728d17beb74e4631c488ad8d1b4aaea7aea (patch)
treeac641eefca0a1cf0ce9efb55d548163082c14477 /backends/networking/sdl_net
parente601c39802adbb64dce4b449c617e1786ef584ed (diff)
downloadscummvm-rg350-eae57728d17beb74e4631c488ad8d1b4aaea7aea.tar.gz
scummvm-rg350-eae57728d17beb74e4631c488ad8d1b4aaea7aea.tar.bz2
scummvm-rg350-eae57728d17beb74e4631c488ad8d1b4aaea7aea.zip
CLOUD: Resolve local machine's IP
Diffstat (limited to 'backends/networking/sdl_net')
-rw-r--r--backends/networking/sdl_net/localwebserver.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/backends/networking/sdl_net/localwebserver.cpp b/backends/networking/sdl_net/localwebserver.cpp
index 134ccd8508..d1dda16f8c 100644
--- a/backends/networking/sdl_net/localwebserver.cpp
+++ b/backends/networking/sdl_net/localwebserver.cpp
@@ -82,11 +82,25 @@ void LocalWebserver::start() {
if (SDLNet_ResolveHost(&ip, NULL, SERVER_PORT) == -1) {
error("SDLNet_ResolveHost: %s\n", SDLNet_GetError());
}
- _address = Common::String::format(
- "http://%u.%u.%u.%u:%u/",
- (ip.host>>24)&0xFF, (ip.host >> 16) & 0xFF, (ip.host >> 8) & 0xFF, ip.host & 0xFF,
- SERVER_PORT
- );
+
+ _address = Common::String::format("http://127.0.0.1:%u/ (unresolved)", SERVER_PORT);
+
+ const char *name = SDLNet_ResolveIP(&ip);
+ if (name == NULL) {
+ warning("SDLNet_ResolveHost: %s\n", SDLNet_GetError());
+ } else {
+ IPaddress localIp;
+ if (SDLNet_ResolveHost(&localIp, name, SERVER_PORT) == -1) {
+ warning("SDLNet_ResolveHost: %s\n", SDLNet_GetError());
+ } else {
+ _address = Common::String::format(
+ "http://%u.%u.%u.%u:%u/",
+ localIp.host & 0xFF, (localIp.host >> 8) & 0xFF, (localIp.host >> 16) & 0xFF, (localIp.host >> 24) & 0xFF,
+ SERVER_PORT
+ );
+ }
+ }
+
_serverSocket = SDLNet_TCP_Open(&ip);
if (!_serverSocket) {
error("SDLNet_TCP_Open: %s\n", SDLNet_GetError());