/[svn]/liblscp/trunk/src/client.c
ViewVC logotype

Diff of /liblscp/trunk/src/client.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3663 by schoenebeck, Sun Dec 22 12:41:28 2019 UTC revision 3664 by schoenebeck, Sun Dec 22 12:53:26 2019 UTC
# Line 23  Line 23 
23  #include <locale.h>  #include <locale.h>
24  #include "common.h"  #include "common.h"
25  #include <sys/time.h>  #include <sys/time.h>
26    #include <sys/errno.h>
27    
28  // Default timeout value (in milliseconds).  // Default timeout value (in milliseconds).
29  #define LSCP_TIMEOUT_MSECS  500  #define LSCP_TIMEOUT_MSECS  500
# Line 157  static void _lscp_client_evt_proc ( void Line 158  static void _lscp_client_evt_proc ( void
158                          } else {                          } else {
159                                  lscp_socket_perror("_lscp_client_evt_proc: recv");                                  lscp_socket_perror("_lscp_client_evt_proc: recv");
160                                  pClient->evt.iState = 0;                                  pClient->evt.iState = 0;
161                                    pClient->iErrno = -errno;
162                          }                          }
163                  }   // Check if select has in error.                  }   // Check if select has in error.
164                  else if (iSelect < 0) {                  else if (iSelect < 0) {
165                          lscp_socket_perror("_lscp_client_evt_proc: select");                          lscp_socket_perror("_lscp_client_evt_proc: select");
166                          pClient->evt.iState = 0;                          pClient->evt.iState = 0;
167                            pClient->iErrno = -errno;
168                  }                  }
169    
170                  // Finally, always signal the event.                  // Finally, always signal the event.
# Line 639  int lscp_client_get_timeout ( lscp_clien Line 642  int lscp_client_get_timeout ( lscp_clien
642          return pClient->iTimeout;          return pClient->iTimeout;
643  }  }
644    
645    /**
646     *  Check whether connection to server is lost.
647     *
648     *  @param pClient  Pointer to client instance structure.
649     *
650     *  @returns @c true if client lost connection to server, @c false otherwise.
651     */
652    bool lscp_client_connection_lost ( lscp_client_t *pClient )
653    {
654        int err = lscp_client_get_errno(pClient);
655        if (err >= 0) return false;
656        return err == -EPIPE || err == -ECONNRESET || err == -ECONNABORTED;
657    }
658    
659    
660  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
661  // Client common protocol functions.  // Client common protocol functions.

Legend:
Removed from v.3663  
changed lines
  Added in v.3664

  ViewVC Help
Powered by ViewVC