EasyManua.ls Logo

Agilent Technologies E5071C - Page 1065

Agilent Technologies E5071C
2685 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
E5071C
1292
'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.
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 the 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. The socket function takes an address
family (input), a socket type (input), and a protocol number (input) as its
parameters.
In (3), the socket address is specified. Note that htons, which is used for
specifying the port number, is a function of WinSock API. This 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 E5071C is made by using the connect function
of WinSock API. If an error occurs, the control returns to the main program
with a message. The connect function takes a socket descriptor (input), a
socket address (input), and the size of the socket address (input) as its
parameters.
OpenSocket
Function OpenSocket(ByVal Hostname As String, ByVal PortNumber As Intege r) As Integer
Dim I_SocketAddress As sockaddr_in
Dim ipAddress As Long
ipAddress = inet_addr(Hostname) '...........(1)

Table of Contents