Integrator's Guide82
© 2017 Nortek AS
7.5 ASCII Data Input Using Ethernet
/* Sample code showing how to connect to and receive data from the Nortek Signature series
* of instruments using the ASCII only data port.
* Compiles on both Windows (requires ws2_32 library) and Linux.
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#ifdef __WIN32__
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#endif
#include <sys/time.h>
#include <unistd.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
static int socket_fd = -1;
#define ASCII_DATA_PORT 9004
char dataBuffer[4096];
int main(void) {
struct sockaddr_in server;
struct hostent *hp;
char *ip_address = "192.168.20.10";
#ifdef __WIN32__
WSADATA version;
WORD mkword = MAKEWORD(2, 2);
int what = WSAStartup(mkword, &version);
if (what != 0) {
printf("Version not supported\n\n");
exit(-1);
}
#endif
/* Create socket */