]> git.stg.codes - stg.git/blobdiff - stglibs/srvconf.lib/netunit.cpp
Fixed "always online" parameter.
[stg.git] / stglibs / srvconf.lib / netunit.cpp
index 9a653d5bf5e76621be46b3b6367a1463dccdf771..aaba3df6afc4aedbd2d7aafb3b74331472ba1017 100644 (file)
  */
 
 //---------------------------------------------------------------------------
  */
 
 //---------------------------------------------------------------------------
-#include <netdb.h>
-#include <arpa/inet.h>
-#include <unistd.h>
+
+#include "stg/netunit.h"
+#include "stg/common.h"
 
 #include <cstdio>
 
 #include <cstdio>
+#include <cerrno>
 #include <cstring>
 
 #include <cstring>
 
-#include "stg/netunit.h"
-#include "stg/common.h"
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <unistd.h>
 
 //---------------------------------------------------------------------------
 
 
 //---------------------------------------------------------------------------
 
@@ -212,6 +214,7 @@ int ret;
 ret = recv(outerSocket, buffer, strlen(OK_HEADER), 0);
 if (ret <= 0)
     {
 ret = recv(outerSocket, buffer, strlen(OK_HEADER), 0);
 if (ret <= 0)
     {
+    printf("Receive header answer error: '%s'\n", strerror(errno));
     errorMsg = RECV_HEADER_ANSWER_ERROR;
     return st_recv_fail;
     }
     errorMsg = RECV_HEADER_ANSWER_ERROR;
     return st_recv_fail;
     }
@@ -261,6 +264,7 @@ int ret;
 ret = recv(outerSocket, buffer, strlen(OK_LOGIN), 0);
 if (ret <= 0)
     {
 ret = recv(outerSocket, buffer, strlen(OK_LOGIN), 0);
 if (ret <= 0)
     {
+    printf("Receive login answer error: '%s'\n", strerror(errno));
     errorMsg = RECV_LOGIN_ANSWER_ERROR;
     return st_recv_fail;
     }
     errorMsg = RECV_LOGIN_ANSWER_ERROR;
     return st_recv_fail;
     }
@@ -318,6 +322,7 @@ int ret;
 ret = recv(outerSocket, buffer, strlen(OK_LOGINS), 0);
 if (ret <= 0)
     {
 ret = recv(outerSocket, buffer, strlen(OK_LOGINS), 0);
 if (ret <= 0)
     {
+    printf("Receive secret login answer error: '%s'\n", strerror(errno));
     errorMsg = RECV_LOGIN_ANSWER_ERROR;
     return st_recv_fail;
     }
     errorMsg = RECV_LOGIN_ANSWER_ERROR;
     return st_recv_fail;
     }
@@ -425,6 +430,7 @@ while (1)
     ret = recv(outerSocket, &bufferS[n++], 1, 0);
     if (ret <= 0)
         {
     ret = recv(outerSocket, &bufferS[n++], 1, 0);
     if (ret <= 0)
         {
+        printf("Receive data error: '%s'\n", strerror(errno));
         close(outerSocket);
         errorMsg = RECV_DATA_ANSWER_ERROR;
         return st_recv_fail;
         close(outerSocket);
         errorMsg = RECV_DATA_ANSWER_ERROR;
         return st_recv_fail;
@@ -436,17 +442,18 @@ while (1)
         Decrypt(buffer, bufferS, &ctx);
         buffer[ENC_MSG_LEN] = 0;
 
         Decrypt(buffer, bufferS, &ctx);
         buffer[ENC_MSG_LEN] = 0;
 
+        printf("%s", buffer);
+
         answerList.push_back(buffer);
 
         for (int j = 0; j < ENC_MSG_LEN; j++)
             {
             if (buffer[j] == 0)
                 {
         answerList.push_back(buffer);
 
         for (int j = 0; j < ENC_MSG_LEN; j++)
             {
             if (buffer[j] == 0)
                 {
+                printf("\n");
                 if (RxCallBack)
                     if (st_ok != RxCallBack(dataRxCallBack, &answerList))
                 if (RxCallBack)
                     if (st_ok != RxCallBack(dataRxCallBack, &answerList))
-                        {
                         return st_xml_parse_error;
                         return st_xml_parse_error;
-                        }
                 return st_ok;
                 }
             }
                 return st_ok;
                 }
             }