EasyManua.ls Logo

Agilent Technologies 4294A - Page 183

Agilent Technologies 4294A
518 pages
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...
Chapter 12 183
Using LAN
Controlling the Agilent 4294A
1. Chapter Title
12. Using LAN 3. Chapter Title
4. Chapter Title
5. Chapter Title
Example 12-5 RecvAscii
Function RecvAscii(dataBuf As String, ByVal maxLength As Integer) As Integer
Dim c As String * 1
Dim length As Integer
dataBuf = ""
While length < maxLength
DoEvents
count = recv(socketId, c, 1, 0) '
If count < 1 Then '
RecvAscii = RECV_ERROR '...................(1)
dataBuf = Chr$(0) '
Exit Function '
End If '
If c = Chr$(10) Then '
dataBuf = dataBuf + Chr$(0) '...................(2)
RecvAscii = NO_ERROR '
Exit Function '
End If '
length = length + count '...................(3)
dataBuf = dataBuf + c '
Wend
RecvAscii = RECV_ERROR
End Function
Disconnection
The subprogram corresponding to disconnection is CloseConnection (Example 12-6).
CloseConnection uses the closesocket function of WinSock API to disconnect communication, and
deletes the socket. The parameter for the closesocket function is Socket Descriptor (input).
Example 12-6 CloseConnection
Sub CloseConnection()
x = closesocket(socketId)
If x = SOCKET_ERROR Then
MsgBox ("ERROR: closesocket = " + Str$(x))
Exit Sub
End If
End Sub
End
The subprogram corresponding to end is EndIt (Example 12-7). EndIt uses the WSACleanup of
WinSock API to disconnect WinSock API. WSACleanup must always be executed at the end of
WinSock.
Example 12-7 EndIt
Sub EndIt()
'Shutdown Winsock DLL
x = WSACleanup()
End Sub

Table of Contents

Other manuals for Agilent Technologies 4294A

Related product manuals