Public Delegate Sub NewPacketEventHandler(ByVal m As myMonitor, ByVal p As myPacket)
Public Event NewPacket As NewPacketEventHandler
Private socks As System.Net.Sockets.Socket
Private ip As System.Net.IPAddress
Private bufer(65535) As Byte
Private Const IOC_VENDOR As Integer = &H18000000
Private Const IOC_IN As Integer = -2147483648
Private Const SIO_RCVALL As Integer = IOC_IN Or IOC_VENDOR Or 1
Private Const SECURITY_BUILTIN_DOMAIN_RID As Integer = &H20
Private Const DOMAIN_ALIAS_RID_ADMINS As Integer = &H220
Public Sub Start()
socks = New System.Net.Sockets.Socket(Net.Sockets.AddressFamily.InterNetwork, _
Net.Sockets.SocketType.Raw, Net.Sockets.ProtocolType.IP)
Dim ep As New System.Net.IPEndPoint(ip, 0)
socks.Bind(ep)
socks.IOControl(SIO_RCVALL, System.BitConverter.GetBytes(1), Nothing)
socks.BeginReceive(bufer, 0, bufer.Length, Net.Sockets.SocketFlags.None, AddressOf RecivePKT, Nothing)
End Sub
Sub RecivePKT(ByVal ar As IAsyncResult)
Dim received As Integer = socks.EndReceive(ar)
Dim pkt(received - 1) As Byte
Array.Copy(bufer, 0, pkt, 0, received)
Dim pock As New myPacket(pkt)
RaiseEvent NewPacket(Me, pock)
socks.BeginReceive(bufer, 0, bufer.Length, Net.Sockets.SocketFlags.None, AddressOf RecivePKT, Nothing)
End Sub
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 18