.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 20th, 2012, 06:49 PM
kmoney kmoney is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 2 kmoney User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m
Reputation Power: 0
VB.NET IP disconnector: what is the correct usage of SetTcpEntry to disconnect

I am trying to create an IP disconnector. This is part from a template that I took that creates a TCPtable. I was trying to add a disconnecting function. However, it does not disconnect.

Code:
Code:
  Dim liste() = {"76.9.24.130" ... ... ...}
    Dim pdwSize As Integer
    Dim iRetVal As Integer
    Dim i As Integer
    Dim TcpTableRow As MIB_TCPROW
    Dim pStructPointer As IntPtr = IntPtr.Zero
    Dim iNumberOfStructures As Integer
    ListView1.Items.Clear()
    iRetVal = GetTcpTable(pStructPointer, pdwSize, 0)
    pStructPointer = Marshal.AllocHGlobal(pdwSize)
    iRetVal = GetTcpTable(pStructPointer, pdwSize, 0)
    iNumberOfStructures = Math.Ceiling((pdwSize - 4) / Marshal.SizeOf(GetType(MIB_TCPROW)))
    For i = 0 To iNumberOfStructures - 1
        Dim pStructPointerTemp As IntPtr = New IntPtr(pStructPointer.ToInt32() + 4 + (i * Marshal.SizeOf(GetType(MIB_TCPROW))))
        TcpTableRow = New MIB_TCPROW()
        With TcpTableRow
            .dwLocalAddr = 0
            .dwState = 0
            .dwLocalPort = 0
            .dwRemoteAddr = 0
            .dwRemotePort = 0
        End With
        'Marshal.PtrToStructure(pStructPointerTemp, TcpTableRow)
        TcpTableRow = CType(Marshal.PtrToStructure(pStructPointerTemp, GetType(MIB_TCPROW)), MIB_TCPROW)
        ' Process each MIB_TCPROW here
        'If Not ((Check1.CheckState = System.Windows.Forms.CheckState.Checked) And (GetIpFromLong(TcpTableRow.dwLocalAddr) = "0.0.0.0" Or GetIpFromLong(TcpTableRow.dwLocalAddr) = "127.0.0.1")) Then
        If Not GetIpFromLong(TcpTableRow.dwRemoteAddr) = "127.0.0.1" And Not GetIpFromLong(TcpTableRow.dwRemoteAddr) = "0.0.0.0" Then
            'Add the data to the ListView control
            With TcpTableRow
                Dim itemAdd As ListViewItem
                itemAdd = ListView1.Items.Add(GetIpFromLong(.dwLocalAddr))
                itemAdd.SubItems.Add(CStr(GetTcpPortNumber(.dwLocalPort)))
                itemAdd.SubItems.Add(GetIpFromLong(.dwRemoteAddr))
                itemAdd.SubItems.Add(CStr(GetTcpPortNumber(.dwRemotePort)))
                itemAdd.SubItems.Add(GetState(.dwState))
            End With
            '-------------- Kill Connection--------------
            If Array.IndexOf(liste, GetIpFromLong(TcpTableRow.dwRemoteAddr)) >= 0 Then
                TcpTableRow.dwState = 12
                SetTcpEntry(TcpTableRow)
            End If
        End If
    Next

Reply With Quote
  #2  
Old February 20th, 2012, 08:08 PM
kmoney kmoney is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 2 kmoney User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m
Reputation Power: 0
come on, can somone please give me a hint?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > VB.NET IP disconnector: what is the correct usage of SetTcpEntry to disconnect

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap