Socket ReceiveAll
Posted
by rielz
on Stack Overflow
See other posts from Stack Overflow
or by rielz
Published on 2010-05-02T14:21:42Z
Indexed on
2010/05/02
15:48 UTC
Read the original article
Hit count: 259
I am trying to capture ip packets in c#. Everything is working fine, except that i only get outgoing packets.
My Code:
using (Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP))
{
sock.Bind(new IPEndPoint(MYADDRESS, 0));
sock.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.HeaderIncluded, true);
sock.IOControl(IOControlCode.ReceiveAll, BitConverter.GetBytes(1), null);
while (true)
{
byte[] buffer = new byte[sock.ReceiveBufferSize];
int count = sock.Receive(buffer);
// ...
}
}
The problem is definitely my pc! But maybe there is a workaround ...
© Stack Overflow or respective owner