class Mu::Pcap::IOPair

For emulating of a pair of connected sockets. Bytes written with write to one side are returned by a subsequent read on the other side.

Use Pair.stream_pair to get a pair with stream semantics. Use Pair.packet_pair to get a pair with packet semantics.

Attributes

other[RW]
read_queue[R]

Public Class Methods

new() click to toggle source
# File lib/woolen_common/pcap/mu/pcap/io_pair.rb, line 18
def initialize
    raise NotImplementedError
end
packet_pair() click to toggle source
# File lib/woolen_common/pcap/mu/pcap/io_pair.rb, line 30
def self.packet_pair
    io1 = Packet.new
    io2 = Packet.new
    io1.other = io2
    io2.other = io1
    return io1, io2
end
stream_pair() click to toggle source
# File lib/woolen_common/pcap/mu/pcap/io_pair.rb, line 22
def self.stream_pair
    io1 = Stream.new
    io2 = Stream.new
    io1.other = io2
    io2.other = io1
    return io1, io2
end

Public Instance Methods

write(bytes) click to toggle source
# File lib/woolen_common/pcap/mu/pcap/io_pair.rb, line 38
def write bytes
    @other.read_queue << bytes
    bytes.size
end