Sha256: 3cc5643a1c14b77a594985c172f102b68d53d4db07e258a8617d51ebac150a94
Contents?: true
Size: 1.23 KB
Versions: 7
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[:transport] ||= :inproc options[:address] ||= options[:context].context.address %i(bind connect).map do |mode| EZMQ::Pair.new mode, options end end end
Version data entries
7 entries across 7 versions & 1 rubygems