Agilent Technologies ES Switch User Manual


 
LAN Interface Supplement 6-11
Controlling the Analyzer via the LAN
Controlling the Analyzer with a C Program
/* Support both Win32 and HP-UX UNIX environment */
#ifdef _WIN32 /* Visual C++ 4.0 will define this */
# define WINSOCK
#endif
#ifndef WINSOCK
# ifndef _HPUX_SOURCE
# define _HPUX_SOURCE
# endif
#endif
#include <stdio.h> /* for fprintf and NULL */
#include <string.h> /* for memcpy and memset */
#include <stdlib.h> /* for malloc(), atol() */
#include <errno.h> /* for strerror */
#ifdef WINSOCK
#include <windows.h>
# ifndef _WINSOCKAPI_
# include <winsock.h> // BSD-style socket functions
# endif
#else /* UNIX with BSD sockets */
# include <sys/socket.h> /* for connect and socket*/
# include <netinet/in.h> /* for sockaddr_in */
# include <netdb.h> /* for gethostbyname */
# define SOCKET_ERROR (-1)
# define INVALID_SOCKET (-1)
typedef int SOCKET;
#endif /* WINSOCK */
#ifdef WINSOCK
/* Declared in getopt.c. See example programs disk. */
extern char *optarg;
extern int optind;
extern int getopt(int argc, char * const argv[], const char* optstring);
#else
# include <unistd.h> /* for getopt(3C) */
#endif
#define COMMAND_ERROR (1)
#define NO_CMD_ERROR (0)
#define SCPI_PORT 5025
#define INPUT_BUF_SIZE (64*1024)
/**************************************************************************
* Display usage
**************************************************************************/
static void usage(char *basename)
{
fprintf(stderr,"Usage: %s [-nqu] <hostname> [<command>]\n", basename);