Sha256: d93ec07961108a6857f3876c06cf1e57444c39e1efe783066498894371f7f2f7
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
require_relative 'context' require_relative 'socket' # Syntactic sugar for 0MQ, because Ruby shouldn't feel like C. module EZMQ # Pair sockets are meant to operate in pairs, as the name implies. They are # bi-directional, with a one-to-one relationship between endpoints. Either # end can send or receive messages. class Pair < EZMQ::Socket # Creates a new Pair socket. # # @param [:bind, :connect] mode a mode for the socket. # @param [Hash] options optional parameters. # @see EZMQ::Socket EZMQ::Socket for optional parameters. # # @return [Pair] a new instance of Pair. # def initialize(mode, **options) fail ArgumentError unless %i(bind connect).include? mode super mode, ZMQ::PAIR, options end end # Returns a pair of EZMQ::Pair sockets connected to each other. # # @param [Hash] options optional parameters. # @see EZMQ::Socket EZMQ::Socket for optional parameters. # # @return [Array<EZMQ::Pair>] # def self.create_linked_pair(**options) options[:context] ||= EZMQ::Context.new options[:protocol] ||= 'inproc' options[:address] ||= options[:context].context.address %i(bind connect).map do |mode| EZMQ::Pair.new mode, options end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ezmq-0.3.7 | lib/ezmq/pair.rb |