Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools


Step-By-Step Example

- Create a standard exe project
- Add one timer and one listbox control on the form1
- Add the following code in form1

Click here to copy the following block
'user defined type required by GetTcpStatistics API call
Private Type MIB_TCPSTATS
  dwRtoAlgorithm As Long  '// timeout algorithm
  dwRtoMin As Long  '// minimum timeout
  dwRtoMax As Long  '// maximum timeout
  dwMaxConn As Long  '// maximum connections
  dwActiveOpens As Long  '// active opens
  dwPassiveOpens As Long  '// passive opens
  dwAttemptFails As Long  '// failed attempts
  dwEstabResets As Long  '// establised connections reset
  dwCurrEstab As Long  '// established connections
  dwInSegs As Long  '// segments received
  dwOutSegs As Long  '// segment sent
  dwRetransSegs As Long  '// segments retransmitted
  dwInErrs As Long  '// incoming errors
  dwOutRsts As Long  '// outgoing resets
  dwNumConns As Long  '// cumulative connections
End Type

Private Declare Function GetTcpStatistics Lib "iphlpapi.dll" ( _
    pStats As MIB_TCPSTATS) As Long

Private Sub Form_Load()
  Timer1.Enabled = True
  Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
  UpdateStats
End Sub

Private Sub UpdateStats()
  Dim arrInfo(14) As String
  Dim arrLablels(14) As String * 30
  Dim tStats     As MIB_TCPSTATS
  Dim lRetValue As Long
  Dim blnIsSent As Boolean
  Dim blnIsRecv As Boolean

  List1.Clear

  lRetValue = GetTcpStatistics(tStats)

  arrLablels(0) = "Timeout algorithm"
  arrLablels(1) = "Minimum timeout"
  arrLablels(2) = "Maximum timeout"
  arrLablels(3) = "Maximum connections"
  arrLablels(4) = "Active opens"
  arrLablels(5) = "Passive opens"
  arrLablels(6) = "Failed attempts"
  arrLablels(7) = "Establised connections reset"
  arrLablels(8) = "Established connections"
  arrLablels(9) = "Segments received"
  arrLablels(10) = "Segment sent"
  arrLablels(11) = "Segments retransmitted"
  arrLablels(12) = "Incoming errors"
  arrLablels(13) = "Outgoing resets"
  arrLablels(14) = "Cumulative connections"

  With tStats
    arrInfo(0) = .dwRtoAlgorithm
    arrInfo(1) = .dwRtoMin
    arrInfo(2) = .dwRtoMax
    arrInfo(3) = .dwMaxConn
    arrInfo(4) = .dwActiveOpens
    arrInfo(5) = .dwPassiveOpens
    arrInfo(6) = .dwAttemptFails
    arrInfo(7) = .dwEstabResets
    arrInfo(8) = .dwCurrEstab
    arrInfo(9) = .dwInSegs
    arrInfo(10) = .dwOutSegs
    arrInfo(11) = .dwRetransSegs
    arrInfo(12) = .dwInErrs
    arrInfo(13) = .dwOutRsts
    arrInfo(14) = .dwNumConns
  End With

  Me.Caption = "Received [" & tStats.dwInSegs & "] " & "Sent [" & tStats.dwOutSegs & "]"

  For i = 0 To 14
    List1.AddItem arrLablels(i) & " : " & arrInfo(i)
  Next
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.