Method: PingTheRouter

Name: PingTheRouter() - 2 Overloads

Parameters.1: intPortNumber (integer)

Parameters.2: strSendToIP (string), intPortNumber (integer)

Returns: Boolean

Description: If pinging an UltraPort Router running on the same computer use Parameters.1, to ping a remote computer (or a specific IP address on the same computer) use Parameters.2.

 

NOTES: The 'PingTheRouter' feature is a built-in feature of the UltraPort Routers. You can call this method whenever you like (within reason, don't put it into an endless loop as that would be the equivalent of a 'Denial of Service' attack against the router) to determine if the UltraPort Router is up and running. IMPORTANT: This is NOT the same as issuing a PING command from the Command Prompt. This method uses a similar call/response functionality and actually transmits a short burst of data to the router profile and waits for the appropriate response. This roundtrip is usually very fast (like a Ping command from a command prompt) but you can use the WaitingForResponse event to 'break' this methods operation (as might be necessary if a form is closing OR a service is stopping, etc).

 

Click to see a VB.Net Example

   Private Function PingLocalRouter(ByVal nPort As Integer) As Boolean

       'nPort is the port number the UltraPort Router

       'is monitoring for proxy messages.

       'This method only works if the UltraPort Router is running on this computer

       Try

           Dim myProxy As New UPRTK.Net2005.RouterProxy

           With myProxy

               If .PingTheRouter(nPort) Then

                   Return True

               Else

                   Return False

               End If

           End With

       Catch ex As Exception

           Return False

       End Try

   End Function

   Private Function PingRemoteRouter(ByVal sIPAddress As String, ByVal nPort As Integer) As Boolean

       'nPort is the port number the UltraPort Router

       'is monitoring for proxy messages.

       'This method can be used to send to any IP address

       'which can be connected to by any IP address on this computer

       Try

           Dim myProxy As New UPRTK.Net2005.RouterProxy

           With myProxy

               If .PingTheRouter(sIPAddress, nPort) Then

                   Return True

               Else

                   Return False

               End If

           End With

       Catch ex As Exception

           Return False

       End Try

   End Function