Agilent Technologies 4294A Service Manual Page 181

  • Download
  • Add to my manuals
  • Print
  • Page
    / 518
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 180
Chapter 12 181
Using LAN
Controlling the Agilent 4294A
1. Chapter Title
12. Using LAN 3. Chapter Title
4. Chapter Title
5. Chapter Title
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()
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 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 the 4294A. If an error occurs
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
Dim I_SocketAddress As sockaddr_in
Dim ipAddress As Long
ipAddress = inet_addr(Hostname) '...................(1)
'Create a new socket
socketId = socket(AF_INET, SOCK_STREAM, 0) '
If socketId = SOCKET_ERROR Then '
Page view 180
1 2 ... 176 177 178 179 180 181 182 183 184 185 186 ... 517 518

Comments to this Manuals

No comments