Agilent Technologies E8257D PSG Instrukcja Użytkownika Strona 135

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
Przeglądanie stron 134
Agilent N516xA, N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide 123
Programming Examples
LAN Programming Interface Examples
*
* $Parameters: $
* (const char *) hostname . . . . Network name of instrument.
* This can be in dotted decimal notation.
* (int) portNumber . . . . . . . The TCP/IP port to talk to.
* Use 5025 for the SCPI port.
*
* $Return: (int) . . . . . . . . A file descriptor similar to open(1).$
*
* $Errors: returns -1 if anything goes wrong $
*
***************************************************************************/
SOCKET openSocket(const char *hostname, int portNumber)
{
struct hostent *hostPtr;
struct sockaddr_in peeraddr_in;
SOCKET s;
memset(&peeraddr_in, 0, sizeof(struct sockaddr_in));
/***********************************************/
/* map the desired host name to internal form. */
/***********************************************/
hostPtr = gethostbyname(hostname);
if (hostPtr == NULL)
{
fprintf(stderr,"unable to resolve hostname '%s'\n", hostname);
return INVALID_SOCKET;
}
/*******************/
/* create a socket */
/*******************/
s = socket(AF_INET, SOCK_STREAM, 0);
if (s == INVALID_SOCKET)
{
fprintf(stderr,"unable to create socket to '%s': %s\n",
hostname, strerror(errno));
return INVALID_SOCKET;
}
Przeglądanie stron 134
1 2 ... 130 131 132 133 134 135 136 137 138 139 140 ... 379 380

Komentarze do niniejszej Instrukcji

Brak uwag