+
+fd = socket(AF_INET, SOCK_STREAM, 0);
+if (fd < 0)
+ {
+ errorStr = "Failed to create socket";
+ 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.";
+ 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, (struct sockaddr *)&addr, sizeof(addr)))
+ {
+ errorStr = "Failed to bind socket";
+ printfd(__FILE__, "Failed to bind listening socket: %s\n", strerror(errno));
+ return -1;
+ }
+
+if (listen(fd, 10))
+ {
+ errorStr = "Failed to listen socket";
+ printfd(__FILE__, "Failed to listen listening socket: %s\n", strerror(errno));
+ return -1;
+ }
+