Click here to Skip to main content
12,296,833 members (64,490 online)
Click here to Skip to main content
Add your own
alternative version


71 bookmarked

RawSocket Class-Create Network Monitoring (Packet Sniffing) Apps

, 11 Apr 2002
Rate this:
Please Sign up or sign in to vote.
A class for creating Network Monitoring Programs


This program illustrates the use of the RawSocket class which is written in C#. The class RawSocket is a packet sniffing class that fires notification events when an IP packet is received. This makes using the class simple. Just declare your RawSocket object, instantiate it, and register to be notified when the event fires.

When the event fires, you are sent event arguments which give your program access to everything in the IP packet including things like IP addresses, port numbers, protocols, message lengths, and of course the message contents.

The included Windows form is a simplified example which basically just shows the origination and destination IP addresses for all incoming packets on a listbox control. The Rawsocket class makes creating more sophisticated network monitoring applications easy.

This program relies on Winsock 2 and runs only on Win2000 or WinXP.

Please email comments and improvements to:

Kember Brown


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Lyle Brown
Web Developer
United States United States
Lyle is a computer programmer in Vancouver, Washington.

You may also be interested in...

Comments and Discussions

ayumiaw23-Jan-08 19:32
memberayumiaw23-Jan-08 19:32 
GeneralARP are Packets not capturing Pin
Aniket Salunkhe2-Nov-06 2:00
memberAniket Salunkhe2-Nov-06 2:00 
GeneralExcellent ! Pin
Gil.Y9-Jun-06 1:14
memberGil.Y9-Jun-06 1:14 
QuestionProblems with Thread? Pin
Robse13-Apr-06 13:41
memberRobse13-Apr-06 13:41 
AnswerRe: Problems with Thread? Pin
Red_angelX24-Apr-07 20:55
memberRed_angelX24-Apr-07 20:55 
AnswerRe: Problems with Thread? Pin
sergios_rus10-Jul-07 13:59
membersergios_rus10-Jul-07 13:59 
QuestionWSAIoctl vs. C# Pin
talbot31-Jan-06 5:09
membertalbot31-Jan-06 5:09 
GeneralSending packets received Pin
doctorcpu28-Sep-05 20:28
memberdoctorcpu28-Sep-05 20:28 
GeneralExplain please Pin
Babs20041-Nov-04 13:34
sussBabs20041-Nov-04 13:34 
Generaldocumentation Pin
wassim suleiman23-Jun-04 5:48
memberwassim suleiman23-Jun-04 5:48 
QuestionThe owning process of a connection? Pin
Johan Danforth12-May-04 21:18
memberJohan Danforth12-May-04 21:18 
atu@ds-fr.com3-May-04 5:51
memberatu@ds-fr.com3-May-04 5:51 
BigRedAtwood13-Sep-04 10:41
memberBigRedAtwood13-Sep-04 10:41 
atu@ds-fr.com13-Sep-04 21:45
memberatu@ds-fr.com13-Sep-04 21:45 
Questionhow about reading TCP header? Pin
mehro21-Feb-04 13:30
membermehro21-Feb-04 13:30 
GeneralSpoofing Pin
Fad B5-Feb-04 0:45
memberFad B5-Feb-04 0:45 
GeneralNot Run in Windows98 Pin
sbf200024-Aug-03 16:45
membersbf200024-Aug-03 16:45 
GeneralRe: Not Run in Windows98 Pin
oglodek28-May-04 6:15
memberoglodek28-May-04 6:15 
GeneralDecoding Socket MessageBuffer Pin
Eric Gibson19-Jun-03 4:54
memberEric Gibson19-Jun-03 4:54 
GeneralRe: Decoding Socket MessageBuffer Pin
kikon22-Jul-03 0:05
memberkikon22-Jul-03 0:05 
GeneralRe: Decoding Socket MessageBuffer Pin
Mike Hunt10-Mar-04 18:21
memberMike Hunt10-Mar-04 18:21 
GeneralRe: Decoding Socket MessageBuffer Pin
RKennison9-Jan-05 8:55
memberRKennison9-Jan-05 8:55 
GeneralRe: Decoding Socket MessageBuffer Pin
dfhgesart26-Jan-05 9:28
sussdfhgesart26-Jan-05 9:28 
Questionwrong numberof packets? Pin
princedom27-May-03 7:24
memberprincedom27-May-03 7:24 
QuestionRawSocket to NAT? Pin
dsandor6-May-03 12:36
memberdsandor6-May-03 12:36 
AnswerRe: RawSocket to NAT? Pin
satyres12-Jun-12 23:37
membersatyres12-Jun-12 23:37 
QuestionWhat does this do? Pin
warmace7-Apr-03 18:40
memberwarmace7-Apr-03 18:40 
AnswerRe: What does this do? Pin
Anonymous18-Apr-03 5:09
sussAnonymous18-Apr-03 5:09 
GeneralSender Pin
Gary Brewer2-Apr-03 4:09
memberGary Brewer2-Apr-03 4:09 
GeneralRe: Sender Pin
Anonymous18-Apr-03 5:12
sussAnonymous18-Apr-03 5:12 
GeneralRe: Sender Pin
Gary Brewer22-Apr-03 4:54
memberGary Brewer22-Apr-03 4:54 version Pin
Calamitous2-Sep-02 23:00
sussCalamitous2-Sep-02 23:00 
GeneralPackets length Pin
Pyt15-Aug-02 4:25
sussPyt15-Aug-02 4:25 
GeneralRe: Packets length Pin
Lyle Smith15-Aug-02 6:39
sussLyle Smith15-Aug-02 6:39 
GeneralRe: Packets length Pin
Pyt15-Aug-02 14:55
memberPyt15-Aug-02 14:55 
GeneralRe: Packets length Pin
lye brown19-Aug-02 5:33
susslye brown19-Aug-02 5:33 
GeneralRe: Packets length Pin
Dain18-Sep-02 4:25
sussDain18-Sep-02 4:25 
GeneralBug SIO_RCVALL Pin
Paul ODell17-Jun-02 9:45
memberPaul ODell17-Jun-02 9:45 
GeneralRe: Bug SIO_RCVALL Pin
Lyle Brown18-Jun-02 10:56
memberLyle Brown18-Jun-02 10:56 
GeneralRe: Bug SIO_RCVALL Pin
summo17-Jan-03 5:19
membersummo17-Jan-03 5:19 
GeneralRe: Bug SIO_RCVALL Pin
Anonymous30-Jan-03 19:42
sussAnonymous30-Jan-03 19:42 
GeneralRe: Bug SIO_RCVALL Pin
farfaraway18-Nov-03 21:55
memberfarfaraway18-Nov-03 21:55 
QuestionHow about a C++ version? Pin
McGarrah15-Apr-02 3:14
memberMcGarrah15-Apr-02 3:14 
AnswerRe: How about a C++ version? Pin
Amit Dey15-Apr-02 6:03
memberAmit Dey15-Apr-02 6:03 
AnswerRe: How about a C++ version? Pin
Kember Brown15-Apr-02 8:42
memberKember Brown15-Apr-02 8:42 
AnswerRe: How about a C++ version? Pin
5.5 cents25-Nov-03 21:28
suss5.5 cents25-Nov-03 21:28 
GeneralUnexplained Pin
Nick Parker13-Apr-02 1:55
memberNick Parker13-Apr-02 1:55 
GeneralRe: Unexplained Pin
Kember Brown13-Apr-02 13:30
memberKember Brown13-Apr-02 13:30 
GeneralSomething's missing Pin
Jason Douglas12-Apr-02 9:29
memberJason Douglas12-Apr-02 9:29 
GeneralRe: Something's missing Pin
Nish [BusterBoy]12-Apr-02 17:50
memberNish [BusterBoy]12-Apr-02 17:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160525.2 | Last Updated 12 Apr 2002
Article Copyright 2002 by Lyle Brown
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid