Gestionar Sockets Ajenos ??

(1/1)

TrashAmbishion:
Lo que quiero hacer es esto

http://www.vbforums.com/showthread.php?503818-RESOLVED-Block-IP

Estoy tratando de llevarlo a .NET si alguien puede ayudar se los agradecere.

Salu2

TrashAmbishion:
Cita de: TrashAmbishion en 19 Junio 2016, 23:19 pm

Lo que quiero hacer es esto

http://www.vbforums.com/showthread.php?503818-RESOLVED-Block-IP

Estoy tratando de llevarlo a .NET si alguien puede ayudar se los agradecere.

Salu2


Solucionado mas tarde subo como lo hice. Salu2

TrashAmbishion:
Código
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
 
       Form1.dgvtcp.Rows.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
           With TcpTableRow
 
               'Aqui desconecto la ip que este conectado a mi
 
                   If GetIpFromLong(.dwRemoteAddr).ToString = "Aqui La Ip" Then
                       .dwState = 12
                       Try
                           SetTcpEntry(TcpTableRow)
                       Catch ex As Exception
                           MessageBox.Show(ex.Message)
                       End Try
                       Exit For
                   End If
 
          End With
Next
Marshal.FreeHGlobal(pStructPointer)
 
 
 

Probado en Windows 8.1

Navegación

[0] Índice de Mensajes