Sniffer

K

Kemo

Hi ppl.
I'm trying to write a sniffer. I can trace all incoming datagrams but no
outgoing. I don't know how to. Can anyone help on this? Here is a sample
code in C#.

_MainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw,
ProtocolType.IP);

_MainSocket.Bind(new IPEndPoint(address, 0));

_MainSocket.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.HeaderIncluded, true);

_MainSocket.IOControl(IOControlCode.ReceiveAll, new byte[4] { 1, 0, 0, 0 },
new byte[4] { 0, 0, 0, 0 });

_ByteData = new byte[_PacketSize];

_Enabled = true;

_MainSocket.BeginReceive(_ByteData, 0, _ByteData.Length, SocketFlags.None,
new AsyncCallback(OnPacketRecive), null);





Thanks
 
P

Patrick Schmid [MVP]

This is a group for Microsoft Word programming. Please find a more
appropriate developer newsgroup or forum.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Outlook 2007 Performance Update: http://pschmid.net/blog/2007/04/13/105
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
***
Customize Office 2007: http://pschmid.net/office2007/customize
RibbonCustomizer Add-In: http://ribboncustomizer.com
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top