Specifications
Chapter 18 323
PSA Programming Examples
Using C Over Socket LAN (Windows NT)
PSA Programming Examples
Using C Over Socket LAN (Windows NT)
This C programming example (getopt.c) compiles in the Windows NT 
environment. In Windows, the routines send() and recv() must be 
used, since fread() and fwrite() may not work on sockets.
The program reads the analyzer’s host name from the command line, 
followed by the SCPI command. It then opens a socket to the analyzer, 
using port 5025, and sends the command. If the command appears to be 
a query, the program queries the analyzer for a response, and prints the 
response.
This example program can also be used as a utility to talk to your 
analyzer from the command prompt on your Windows NT PC, or from 
within a script.
/***************************************************************************
 getopt(3C)     getopt(3C)
 NAME
 getopt - get option letter from argument vector
 SYNOPSIS
 int getopt(int argc, char * const argv[], const char *optstring);
 extern char *optarg;
 extern int optind, opterr, optopt;
 DESCRIPTION
 getopt returns the next option letter in argv (starting from argv[1])
 that matches a letter in optstring. optstring is a string of
 recognized option letters; if a letter is followed by a colon, the
 option is expected to have an argument that may or may not be
 separated from it by white space. optarg is set to point to the start
 of the option argument on return from getopt.
 getopt places in optind the argv index of the next argument to be
 processed. The external variable optind is initialized to 1 before










