EasyManua.ls Logo

Nortek Signature Series - Page 84

Nortek Signature Series
85 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Integrator's Guide84
© 2017 Nortek AS
if (WSAGetLastError() == WSAETIMEDOUT) {
/* No data received within timeout period. Could either loop or
* re-open / check connection at this point.
*/
printf("Socket read timed out\n\n");
} else {
/* Local socket error. Re-connect required. */
wchar_t *s = NULL;
FormatMessageW(
FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, WSAGetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPWSTR) &s, 0, NULL);
printf("Socket read failed %S\n\n", s);
LocalFree(s);
}
}
break;
}
#else
if ((r = read(socket_fd, &c, 1)) <= 0) {
if (r == 0) {
/* Instrument terminated socket for some reason. Re-connect required. */
printf("Server terminated socket\n\n");
} else {
if (errno == EAGAIN) {
/* No data received within timeout period. Could either loop or
* re-open / check connection at this point.
*/
printf("Socket read timed out\n\n");
} else {
/* Local socket error. Re-connect required. */
printf("Socket read failed (%d) %s\n\n", errno, strerror(errno));
}
}
break;
}
#endif
dataBuffer[length++] = c;
if (length >= sizeof(dataBuffer)) {
printf("Truncating data input...\n\n");
length = sizeof(dataBuffer) - 1;
}
/* Set last byte to 0 so that strings are zero terminated. */
dataBuffer[length] = 0;
if ('\n' == c) {
/* '\n' indicates end-of-line for ASCII data. */

Table of Contents

Related product manuals