From 8b15fd52c452bbd8857ef5c9a89cb5a301ed6c51 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Sat, 28 Apr 2012 00:51:21 +0200 Subject: [PATCH] Fixed Controller compiling, upped socket lib verbosity, fixed JSON::Value null -> string convert, fixed Makefile install command. --- util/json.cpp | 6 +++++- util/socket.cpp | 12 ++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/util/json.cpp b/util/json.cpp index 7542ed37..d4b3efc4 100644 --- a/util/json.cpp +++ b/util/json.cpp @@ -254,7 +254,11 @@ JSON::Value::operator std::string(){ if (myType == STRING){ return strVal; }else{ - return toString(); + if (myType == EMPTY){ + return ""; + }else{ + return toString(); + } } } diff --git a/util/socket.cpp b/util/socket.cpp index 603075ee..4ddcfb81 100644 --- a/util/socket.cpp +++ b/util/socket.cpp @@ -454,7 +454,7 @@ Socket::Server::Server(int port, std::string hostname, bool nonblock){ sock = socket(AF_INET6, SOCK_STREAM, 0); if (sock < 0){ #if DEBUG >= 1 - fprintf(stderr, "Could not create socket! Error: %s\n", strerror(errno)); + fprintf(stderr, "Could not create socket %s:%i! Error: %s\n", hostname.c_str(), port, strerror(errno)); #endif return; } @@ -468,7 +468,7 @@ Socket::Server::Server(int port, std::string hostname, bool nonblock){ struct sockaddr_in6 addr; addr.sin6_family = AF_INET6; addr.sin6_port = htons(port);//set port - if (hostname == "0.0.0.0"){ + if (hostname == "0.0.0.0" || hostname.length() == 0){ addr.sin6_addr = in6addr_any; }else{ inet_pton(AF_INET6, hostname.c_str(), &addr.sin6_addr);//set interface, 0.0.0.0 (default) is all @@ -487,14 +487,14 @@ Socket::Server::Server(int port, std::string hostname, bool nonblock){ } }else{ #if DEBUG >= 1 - fprintf(stderr, "Binding failed, retrying as IPv4... (%s)\n", strerror(errno)); + fprintf(stderr, "Binding %s:%i failed, retrying as IPv4... (%s)\n", hostname.c_str(), port, strerror(errno)); #endif close(); } sock = socket(AF_INET, SOCK_STREAM, 0); if (sock < 0){ #if DEBUG >= 1 - fprintf(stderr, "Could not create socket! Error: %s\n", strerror(errno)); + fprintf(stderr, "Could not create socket %s:%i! Error: %s\n", hostname.c_str(), port, strerror(errno)); #endif return; } @@ -508,7 +508,7 @@ Socket::Server::Server(int port, std::string hostname, bool nonblock){ struct sockaddr_in addr4; addr4.sin_family = AF_INET; addr4.sin_port = htons(port);//set port - if (hostname == "0.0.0.0"){ + if (hostname == "0.0.0.0" || hostname.length() == 0){ addr4.sin_addr.s_addr = INADDR_ANY; }else{ inet_pton(AF_INET, hostname.c_str(), &addr4.sin_addr);//set interface, 0.0.0.0 (default) is all @@ -527,7 +527,7 @@ Socket::Server::Server(int port, std::string hostname, bool nonblock){ } }else{ #if DEBUG >= 1 - fprintf(stderr, "IPv4 binding also failed, giving up. (%s)\n", strerror(errno)); + fprintf(stderr, "IPv4 binding %s:%i also failed, giving up. (%s)\n", hostname.c_str(), port, strerror(errno)); #endif close(); return;