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 |
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. |
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. |