locked
help with IOControlCode.ReceiveAll error message. network monitoring RRS feed

  • Question

  •  

     

    Dear all

    i am trying to monitor the mobile device's own ipaddress, all the activites (both incoming and outgoing ones). the code does work in the windows desktop environment. however, when i put the same code in to the windows environment, i have one error regarding "IOControlCode.ReceiveAll", and the error message: "name IOControlCode.ReceiveAll is not declared", i tried to put the system.net.sockets in front of it. it did not work either. 

    coding platform: vb.net windows mobile 6

    any one has any suggestions or anyone can help me with this error?

    thanks very much! 

    coding block:

    If

     

    Not bContinueCapturing Then

     

    'Start capturing the packets...

    btnStart.Text =

    "&Stop"

    bContinueCapturing =

    True

     

    'For sniffing the socket to capture the packets has to be a raw socket, with the

     

    'address family being of type internetwork, and protocol being IP

    mainSocket =

    New Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP)

     

    'Bind the socket to the selected IP address

    mainSocket.Bind(

    New IPEndPoint(IPAddress.Parse(cmbInterfaces.Text), 0))

     

    'Set the socket options

     

    'Applies only to IP packets

     

    'Set the include the header

    mainSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.HeaderIncluded,

    True)

     

    'option to true

     

    Dim byTrue As Byte() = New Byte(3) {1, 0, 0, 0}

     

    Dim byOut As Byte() = New Byte(3) {1, 0, 0, 0}

     

    'Capture outgoing packets

     

    'Socket.IOControl is analogous to the WSAIoctl method of Winsock 2

     

    'Equivalent to SIO_RCVALL constant

     

    'of Winsock 2

    mainSocket.IOControl(IOControlCode.ReceiveAll, byTrue, byOut)

     

    'Start receiving the packets asynchronously

    mainSocket.BeginReceive(byteData, 0, byteData.Length, SocketFlags.None,

    New AsyncCallback(AddressOf OnReceive), Nothing)

     

    Else

    btnStart.Text =

    "&Start"

    bContinueCapturing =

    False

     

    'To stop capturing the packets close the socket

    mainSocket.Close()

     

    End If

    Monday, September 14, 2009 4:34 PM

Answers

All replies