Introduction

Pcap provides packet processing library for rapid development on the top of JVM languages.

Hello Pcap!

"Hello pcap!" implementation in different JVM languages.

Java
Kotlin
Scala
Clojure
Groovy
Java
var pcaps = Service.create("PcapService");
var pcap = pcaps.live(pcaps.lookupInterfaces(), new PcapLiveOptions());
pcap.loop(10, (args, header, buffer) -> {
System.out.println("Args : " + args);
System.out.println("Header : " + header);
System.out.println("Packet : " + buffer);
}, "Hello pcap!");
pcap.close();
Kotlin
val pcaps = Service.create("PcapService")
val pcap = pcaps.live(pcaps.lookupInterfaces(), PcapLiveOptions())
pcap.loop(10, { args, header, buffer ->
println("Args : $args")
println("Header : $header")
println("Packet : $buffer")
}, "Hello pcap!")
pcap.close()
Scala
val pcaps = Service.create("PcapService")
val pcap = pcaps.live(pcaps.lookupInterfaces(), new PcapLiveOptions())
pcap.loop(10, (args: String, header: PacketHeader, buffer: PacketBuffer) => {
println("Args : ", args)
println("Header : ", header)
println("Packet : ", buffer)
}, "Hello pcap!")
pcap.close()
Clojure
(def pcaps (. Service (create "PcapService")))
(def pcap (.live pcaps (.lookupInterfaces pcaps) (PcapLiveOptions.)))
(def handler (reify PacketHandler (gotPacket [this args header buffer]
(println "Args : " args)
(println "Header : " header)
(println "Buffer : " buffer))))
(.loop pcap 10 handler "Hello pcap!")
(.close pcap))
Groovy
def pcaps = Service.create("PcapService")
def pcap = pcaps.live(pcaps.lookupInterfaces(), new PcapLiveOptions())
pcap.loop(10, { args, header, buffer ->
println("Args : " + args)
println("Header : " + header)
println("Packet : " + buffer)
}, "Hello pcap!");
pcap.close()

Source: https://github.com/ardikars/pcap-example

Disclimers

  • Every classes, methods, or fields annotated with @Incubating might never make it into a stable release.

  • Every classes, methods, or fields annotated with @Incubating might be changed or removed at any time.

  • Every classes, methods, or fields annotated with @Incubating does not imply that the functionality being tested will be present in any particular stable release.

This project does not yet have a stable release. Every artifact published on "maven central" is only for testing.