GuoWenxue
2022-04-19 ea435789dc2fab30ec16fa765a0b6577fe08166a
apue/project_socket/main/client_main.c
@@ -35,7 +35,6 @@
int main(int argc, char **argv)
{
   int                  rv = -1;
   int                  pr_times = 0;
   int                  port;
   char                *serverip;
   int                  interval = 30; /* default report termperature every 30 seconds */
@@ -110,7 +109,7 @@
      /* set logger to $logfile with level info */
      if( logger_init(logfile, LOG_LEVEL_INFO) < 0 )
      {
         fprintf(stderr, "Initial logger file '%s' failure: %s\n", strerror(errno));
         fprintf(stderr, "Initial logger file '%s' failure: %s\n", logfile, strerror(errno));
         return 1;
      }
@@ -163,23 +162,17 @@
      /* start connect to server if not connected */
      if( sock.fd < 0 )
      {
         if( 0 == (pr_times % 10) )
         {
            log_info("socket not connect, start connect it now.\n");
         }
         socket_connect(&sock);
      }
      /* check socket connected or not  */
      if( sock_check_connect(sock.fd) < 0 )
      {
         pr_times ++;
         if( 0 == (pr_times % 10) )
         if( sock.fd > 0 )
         {
            log_error("socket got disconnected, terminate it and reconnect now.\n");
            pr_times = 0;
                socket_term(&sock); /* close the soket */
         }
         socket_term(&sock); /* close the soket */
      }
      /* socket disconnected */