Agilent Technologies E4406A VSA Satellite Radio User Manual


 
Chapter 3 163
Programming Examples
Using C Programming Over Socket LAN
SOCKET instSock;
char *charBuf = (char *) malloc(INPUT_BUF_SIZE);
char *basename;
int chr;
char command[1024];
char *destination;
unsigned char quiet = 0;
unsigned char show_errs = 0;
int number = 0;
basename = strrchr(argv[0], /);
if (basename != NULL)
basename++ ;
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++]);