-running = true;
-rpcServer = new xmlrpc_c::serverAbyss(
- rpcRegistry,
- rpcConfigSettings.GetPort(),
- "/var/log/stargazer_rpc.log"
- );
-if (pthread_create(&tid, NULL, Run, this))
+
+fd = socket(AF_INET, SOCK_STREAM, 0);
+if (fd < 0)
+ {
+ errorStr = "Failed to create socket";
+ logger("Cannot create a socket: %s", strerror(errno));
+ printfd(__FILE__, "Failed to create listening socket: %s\n", strerror(errno));
+ return -1;
+ }
+
+int flag = 1;
+
+if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag)))
+ {
+ errorStr = "Setsockopt failed.";
+ logger("setsockopt error: %s", strerror(errno));
+ printfd(__FILE__, "Setsockopt failed: %s\n", strerror(errno));
+ return -1;
+ }
+
+struct sockaddr_in addr;
+addr.sin_family = AF_INET;
+addr.sin_port = htons(rpcConfigSettings.GetPort());
+addr.sin_addr.s_addr = inet_addr("0.0.0.0");
+
+if (bind(fd, reinterpret_cast<sockaddr *>(&addr), sizeof(addr)))
+ {
+ logger("Cannot bind the socket: %s", strerror(errno));
+ errorStr = "Failed to bind socket";
+ printfd(__FILE__, "Failed to bind listening socket: %s\n", strerror(errno));
+ return -1;
+ }
+
+if (listen(fd, 10))