Sha256: 4f0a78f7f689cc79a60839b95ae99b4c5a186f727287d7520927a29f0265e318

Contents?: true

Size: 506 Bytes

Versions: 2

Compression:

Stored size: 506 Bytes

Contents

require "jruby-pcap/packet"
java_import java.sql.Timestamp

module Jruby::Pcap
  class LiveHandle

    include Enumerable

    def initialize(interface)
      @interface = interface
    end

    def each
      handle = @interface.open_live(1024, PcapNetworkInterface::PromiscuousMode::PROMISCUOUS, 0)
      while true do
        next_packet = handle.next_packet_ex
        if next_packet
          yield Packet.new(next_packet, handle)
        else
          break
        end
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jruby-pcap-0.1.2 lib/jruby-pcap/live_handle.rb
jruby-pcap-0.1.1 lib/jruby-pcap/live_handle.rb