Agilent Technologies E4406A VSA Satellite Radio User Manual


 
156 Chapter 3
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
}