4

I want to write a program that has 2 threads , one thread continuously captures packets from the network and dumps them in a buffer every t seconds and the other thread continuously reads this buffer and processes it every t seconds.. Can this be done in C ? or will Java be a better option ?

trinity
  • 10,394
  • 15
  • 49
  • 67
  • Thanks everyone ! I'm used to using threads in java and doing packet capture in C using libpcap.Can threads be used in C with equal ease as in java ? Is there any specific info on net that would help me.. – trinity Jan 13 '10 at 13:44

3 Answers3

5

C and libpcap

Frunsi
  • 7,099
  • 5
  • 36
  • 42
3

The answer here is the famous "libpcap". Use your favourite language as long as there is a good libpcap wrapper available for it.

So pick your language, check the existence of the wrapper and go on. If there is no wrapper for this language, either change your choice, or create your own wrapper

almathie
  • 731
  • 5
  • 22
1

It can certainly be done in C.

Doing it in Java will depend on whether you have access to a packet capturing library for Java (assuming you mean that you want to capture arbitrary packets, not just ones specifically directed to your application).

caf
  • 233,326
  • 40
  • 323
  • 462