Page 1 sur 1

NSFGetServerLatency

MessagePublié: 02 Août 2005 à 13:08
par Stephane Maillard
I have only used NSFGetServerLatency from LotusScript, and it seems to work as advertised. For example, you can try the code below in a button to test it (and NSPingServer, too) on your system.[syntax="ls"]Const Button = "Server Latency"

' Const APIModule = "NNOTES" ' Windows
Const APIModule = "libnotes_r.a" ' AIX

Declare Function NSFGetServerLatency Lib APIModule Alias "NSFGetServerLatency" _
( Byval S As String, Byval T As Long, A As Long, B As Long, V As Integer) As Integer

Declare Function NSPingServer Lib APIModule Alias "NSPingServer" _
( Byval S As String, L As Long, pC As Long) As Integer

Declare Function OSLoadString Lib APIModule Alias "OSLoadString" _
( Byval H As Long, Byval S As Integer, Byval B As String, Byval nB As Integer) As Integer

Sub Click(Source As Button)
s$ = Trim$(Inputbox$("Server name:", Button, ""))
If s$ = "" Then Exit Sub

v% = NSPingServer(s$, a&, 0)
If Not v% = 0 Then
APIError v%
Exit Sub
End If

v% = NSFGetServerLatency(s$, 30000, tC&, tS&, sV%)
If Not v% = 0 Then
APIError v%
Exit Sub
End If

Messagebox "Server: " & s$ _
& Chr$(10) & "Availability: " & Cstr(a&) & "%" _
& Chr$(10) & "Outbound: " & Cstr(tC&) & " ms" _
& Chr$(10) & "Inbound: " & Cstr(tS&) & " ms" _
& Chr$(10) & "Version: " & Cstr(sV%) _
, 64, Button
End Sub

Sub APIError(V As Integer)
m$ = String$(1024, " ")
OSLoadString 0, V And &H3FFF, m$, 1024
p% = Instr(m$, Chr$(0))
If Not p% = 0 Then m$ = Left$(m$, p% - 1)
If m$ = "" Or m$ = "No error" Then m$ = "Unknown error (&H" & Hex$(v%) & ")"
Messagebox m$, 16, Button
End Sub[/syntax]