class EZMQ::Server
Reply socket that listens for and replies to requests.
Public Class Methods
new(mode = :bind, **options)
click to toggle source
Creates a new Server
socket.
@param [:bind, :connect] mode (:bind) a mode for the socket. @param [Hash] options optional parameters @see EZMQ::Socket
EZMQ::Socket
for optional parameters.
@return [Server] a new instance of Server
Calls superclass method
EZMQ::Socket::new
# File lib/ezmq/reply.rb, line 15 def initialize(mode = :bind, **options) super mode, ZMQ::REP, options end
Public Instance Methods
listen() { |receive| ... }
click to toggle source
Listens for a request, and responds to it.
If no block is given, responds with the request message.
@yield message passes the message received to the block. @yieldparam [String] message the message received. @yieldreturn [void] the message to reply with.
@return [void] the return from handler.
# File lib/ezmq/reply.rb, line 29 def listen loop do if block_given? send yield receive else send receive end end end