beautypg.com

Agilent Technologies N5183A MXG User Manual

Page 123

background image

Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide

113

Programming Examples

LAN Programming Interface Examples

{

fprintf(stderr,"unable to create socket to '%s': %s\n",

hostname, strerror(errno));

return INVALID_SOCKET;

}

return s;

}

/***************************************************************************

*

> $Function: commandInstrument$

*

* $Description: send a SCPI command to the instrument.$

*

* $Parameters: $

* (FILE *) . . . . . . . . . file pointer associated with TCP/IP socket.

* (const char *command) . . SCPI command string.

* $Return: (char *) . . . . . . a pointer to the result string.

*

* $Errors: returns 0 if send fails $

*

***************************************************************************/

int commandInstrument(SOCKET sock,

const char *command)

{

int count;

/* fprintf(stderr, "Sending \"%s\".\n", command); */

if (strchr(command, '\n') == NULL) {

fprintf(stderr, "Warning: missing newline on command %s.\n", command);

}

count = send(sock, command, strlen(command), 0);

if (count == SOCKET_ERROR) {

return COMMAND_ERROR;

}

return NO_CMD_ERROR;

}

This manual is related to the following products: