Agilent Technologies E4406A VSA manual Programming Examples, Using C Programming Over Socket LAN

Models: E4406A VSA

1 406
Download 406 pages 63.49 Kb
Page 156
Image 156
Manual background

Programming Examples

Using C Programming Over Socket LAN

/* If we hit a newline, stop. */ if (*ptr == ’\n’) {

ptr++; err = 0; break;

}

ptr++;

}

*ptr = ’\0’;

if (err) { return NULL;

} else {

return result;

}

#else

/***********************************************************************

*Simpler UNIX version, using file I/O. recv() version works too.

*This demonstrates how to use file I/O on sockets, in UNIX.

***********************************************************************/

FILE * instFile;

instFile = fdopen(sock, "r+"); if (instFile == NULL)

{

fprintf(stderr, "Unable to create FILE * structure : %s\n", strerror(errno));

exit(2);

}

return fgets(result, maxLength, instFile); #endif

}

156

Chapter 3

Page 156
Image 156
Agilent Technologies E4406A VSA manual Programming Examples, Using C Programming Over Socket LAN