Agilent Technologies 4294A Service Manual Page 183

  • Download
  • Add to my manuals
  • Print
  • Page
    / 518
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 182
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
Page view 182
1 2 ... 178 179 180 181 182 183 184 185 186 187 188 ... 517 518

Comments to this Manuals

No comments