IP Status API

Use the Computer Cabling Redundancy IP Status API to monitor the state of connections to IP addresses.

The following BASIC script generates or clears an alarm depending upon the state of the connection to an IP address.

Declare Function InitSocketChange CDecl Lib "redwinsock.dll" _
  () As Long
Declare Function WaitSocketChange CDecl Lib "redwinsock.dll" _
 (ByVal data As Long, ByVal timeout As Long) As Long
Declare Function CloseSocketChange CDecl Lib "redwinsock.dll" _
 (ByVal data As Long) As Boolean
Declare Function GetNextSocketChange CDecl Lib "redwinsock.dll" _
 (ByVal data As Long, ByVal node As String, ByRef ipAddress As Long, _
  ByRef state As Long) As Long
Declare Function CvtIPAddress(x As Long) As String
Sub Main()
  Dim data As Long
  im node As String
  Dim ipAddress As Long
  Dim state As Long
  Dim n256 As Long
  n256 = 256
  data = InitSocketChange()
  If data <> 0 Then
    While 1
       = WaitSocketChange(data, 5000)
      If i = 1 Then
        ode = Space(256)
        While GetNextSocketChange(data, node, ipAddress, state)
          ipStr$ = CvtIPAddress(ipAddress)
          message$ = "IP address " & ipStr$
          refId$ = ipAddress
          If state = 2 Then
            AlarmUpdate "", "IPALARM", "$SYSTEM", AM_RESET_M, _
                       message$, "", refId$
          Else
            AlarmGenerate "", "IPALARM", "$SYSTEM", message$, _
                       "", refId$, True
          End If
          node = Space(256)
        Wend
      End If
    Wend
    i = CloseSocketChange(data)
  End If
End Sub
Function CvtIPAddress(x As Long) As String
  mod1 = ipAddress Mod n256
  If mod1 < 0 Then mod1 = 256 + mod1
  mod2 = ipAddress / n256 Mod n256
  f mod2 < 0 Then mod2 = 256 + mod2
  mod3 = ipAddress / (n256 * n256) Mod n256
  If mod3 < 0 Then mod3 = 256 + mod3
  mod4 = ipaddress / (n256 * n256 * n256) Mod n256
  If mod4 < 0 Then mod4 = 256 + mod4
  CvtIPAddress = mod1 & "." & mod2 & "." & mod3 & "." & mod4
End Function