Agilent Technologies E5071C User's Guide Page 188

  • Download
  • Add to my manuals
  • Print
  • Page
    / 551
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 187
188 Chapter 12
Sample Application Programs
Controlling Using Telnet Server
Procedures in each step in Figure 12-6 are described below.
Startup
The procedure corresponding to Startup is StartIt (Example 12-8). StartIt launches and
initialize
WinSock API with WSAStartup in WinSock API, whose version is in the
part 1 of Figure 12-5. The function WSAStartup should be always used when initiating
WinSock. This function takes version number (input) and launching information (output)
as its parameters.
Example 12-8 StartIt
Sub StartIt()
Dim StartUpInfo As WSAData
'Version 1.1 (1*256 + 1) = 257
'version 2.0 (2*256 + 0) = 512
'Get WinSock version
Sheets("Sheet1").Select
Range("C2").Select
version = ActiveCell.FormulaR1C1
'Initialize Winsock DLL
x = WSAStartup(version, StartUpInfo)
End Sub
Socket Creation and Connection
The procedure for Socket Creation and Connection is OpenSocket (Example 12-9).
OpenSocket makes a connection to an instrument associated with the IP address specified
with the input parameter Hostname. It uses a socket of the port specified with the input
parameter PortNumber. Each functional part of OpenSocket is described below.
In (1), the inet_aadr function of WinSock API is used to convert an IP address delimited by
“.” to an Internet address.
In (2), a new socket is created with socket function of
WinSock API and its socket
descriptor is obtained. If an error occurs, the control returns to the main program with a
message. socket function takes parameters for an address family (input), a socket type
(input), and a protocol number (input).
In (3), the socket address is specified. Note that htons, which is used for specifying the port
number, is a function of WinSock API. The function converts a 2-byte integer from the
Windows byte order (little endian) to the network byte order (big endian).
In (4), a connection to the
E5061A/E5062A is made using connect function of
WinSock API. If an error occurs, the control returns to the main program with a
message. connect function takes parameters for a socket descriptor (input), a socket
address (input), and size of the socket address (input).
Page view 187
1 2 ... 183 184 185 186 187 188 189 190 191 192 193 ... 550 551

Comments to this Manuals

Vikiehs 04 Jan 2024 | 14:20:06

urenrjrjkvnm