![Agilent Technologies 4294A Скачать руководство пользователя страница 181](http://html.mh-extra.com/html/agilent-technologies/4294a/4294a_programming-manual_2867882181.webp)
Chapter 12
181
Using LAN
Controlling the Agilent 4294A
1. Ch
apter
T
itle
12
. Usin
g LAN
3
. Chap
ter T
itle
4
. Chap
te
r T
itle
5. Chap
te
r T
itle
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 '
Содержание 4294A
Страница 4: ...4 ...
Страница 18: ...18 Contents ...
Страница 24: ...24 Chapter1 To make effective use of this manual Other manuals attached to this unit ...
Страница 94: ...94 Chapter6 Reading Writing Measurement Data Reading Writing Data ...
Страница 110: ...110 Chapter7 Processing Measurement Results Analyzing Measurement Results ...
Страница 130: ...130 Chapter9 Communication with External Equipment Using the I O Ports Sample Program to Use the I O Port ...
Страница 136: ...136 Chapter10 Handling Errors Sample program for error handling ...
Страница 246: ...246 13 Application Sample Programs File Transfer Function ...
Страница 254: ...254 Chapter15 Setting the Display LCD Sample program for setting the LCD screen ...
Страница 507: ...Index Index 507 Index ...
Страница 508: ...508 Index Index ...
Страница 509: ...Index Index 509 Index ...
Страница 510: ...510 Index Index ...
Страница 511: ...Index Index 511 Index ...
Страница 512: ...512 Index Index ...
Страница 513: ...Index Index 513 Index ...
Страница 514: ...514 Index Index ...
Страница 515: ...Index Index 515 Index ...
Страница 516: ...516 Index Index ...
Страница 517: ...Index Index 517 Index ...
Страница 518: ...518 Index Index ...