Agilent Technologies 4294A Programming Manual page 181

Precision impedance analyzer
Hide thumbs Also See for 4294A:
Table of Contents

Advertisement

Below are described subprograms corresponding to each step in Figure 12-6:
Startup
The subprogram corresponding to Startup is StartIt (Example 12-2). StartIt uses the version of
WinSock API entered into the part 1 of Figure 12-5 to start up and initialize WinSock API with the
WSAStartup function of WinSock API. This WSAStartup function must always be executed at the
start of WinSock. Parameters for this function are version No. (input) and startup information
(output).
Example 12-2
StartIt
Sub StartIt()
End Sub
Socket creation and connection
The subprogram corresponding to socket creation and connection is OpenSocket (Example 12-3).
OpenSocket establishes a connection to the socket of the port specified by PortNumber, an input
parameter, on a machine with the IP address specified by Hostname, an input parameter. Below are
described steps of OpenSocket:
In (1), the inet_aadr function of WinSock API is used to convert an IP address delimited by "." to an
Internet address.
In (2), the socket function of WinSock API is used to create a new socket and acquire the descriptor
of this socket. If an error occurs during this operation, the function outputs a message and returns
processing to the main program. Parameters for the socket function are Address Family (input),
Socket Type (input) and Protocol No. (input).
In (3), a socket address is set. htons used at setting of the port No. is a WinSock API function that
converts a 2-byte integer from the Windows-type byte order (little endian) to the network byte order
(big endian).
In (4), the connect function of WinSock is used for connection to
during this operation, the function outputs a message and returns processing to the main program.
Parameters for the connect function are Socket Descriptor (input), Socket Address and Socket
Address Size (input).
Example 12-3
OpenSocket
Function OpenSocket(ByVal Hostname As String, ByVal PortNumber As Integer) As
Integer
Chapter 12
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)
Dim I_SocketAddress As sockaddr_in
Dim ipAddress As Long
ipAddress = inet_addr(Hostname)
'Create a new socket
socketId = socket(AF_INET, SOCK_STREAM, 0)
If socketId = SOCKET_ERROR Then
Using LAN
Controlling the Agilent 4294A
the
4294A. If an error occurs
'...................(1)
'
'
181

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents