LAN Interface Supplement 6-19
Controlling the Analyzer via the LAN
Controlling the Analyzer with a C Program
else
basename = argv[0];
while ( ( chr = getopt(argc,argv,"qune")) != EOF )
switch (chr)
{
case 'q': quiet = 1; break;
case 'n': number = 1; break ;
case 'e': show_errs = 1; break ;
case 'u':
case '?': usage(basename); exit(1) ;
}
/* now look for hostname and optional <command> */
if (optind < argc)
{
destination = argv[optind++] ;
strcpy(command, "");
if (optind < argc)
{
while (optind < argc) {
/* <hostname> <command> provided; only one command string */
strcat(command, argv[optind++]);
if (optind < argc) {
strcat(command, " ");
} else {
strcat(command, "\n");
}
}
}
else
{
/* Only <hostname> provided; input on <stdin> */
strcpy(command, "");
if (optind > argc)
{
usage(basename);
exit(1);
}
}
}
else
{
/* no hostname! */
usage(basename);
exit(1);
}
/**********************************************/
/* open a socket connection to the instrument */
/**********************************************/
#ifdef WINSOCK
if (init_winsock() != 0) {
exit(1);
}
#endif /* WINSOCK */
instSock = openSocket(destination, SCPI_PORT);
if (instSock == INVALID_SOCKET) {