EasyManua.ls Logo

Agilent Technologies n5181a - Page 124

Agilent Technologies n5181a
366 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...
114 Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide
Programming Examples
LAN Programming Interface Examples
/**************************************************************************
* recv_line(): similar to fgets(), but uses recv()
**************************************************************************/
char * recv_line(SOCKET sock, char * result, int maxLength)
{
#ifdef WINSOCK
int cur_length = 0;
int count;
char * ptr = result;
int err = 1;
while (cur_length < maxLength) {
/* Get a byte into ptr */
count = recv(sock, ptr, 1, 0);
/* If no chars to read, stop. */
if (count < 1) {
break;
}
cur_length += count;
/* If we hit a newline, stop. */
if (*ptr == '\n') {
ptr++;
err = 0;
break;
}
ptr++;
}
*ptr = '\0';
if (err) {
return NULL;
} else {
return result;
}
#else
/***********************************************************************

Table of Contents

Other manuals for Agilent Technologies n5181a

Related product manuals