Class: MessagePack::RPC::UDPServerTransport
- Inherits:
-
Object
- Object
- MessagePack::RPC::UDPServerTransport
- Defined in:
- lib/msgpack/rpc/transport/udp.rb
Defined Under Namespace
Classes: ResponseSender, ServerSocket
Instance Method Summary collapse
-
#close ⇒ Object
ServerTransport interface.
-
#initialize(address) ⇒ UDPServerTransport
constructor
A new instance of UDPServerTransport.
-
#listen(server) ⇒ Object
ServerTransport interface.
Constructor Details
#initialize(address) ⇒ UDPServerTransport
Returns a new instance of UDPServerTransport.
124 125 126 127 |
# File 'lib/msgpack/rpc/transport/udp.rb', line 124 def initialize(address) @address = address @sock = nil end |
Instance Method Details
#close ⇒ Object
ServerTransport interface
152 153 154 155 156 |
# File 'lib/msgpack/rpc/transport/udp.rb', line 152 def close return unless @lsock @lsock.detach if @lsock.attached? @lsock.close end |
#listen(server) ⇒ Object
ServerTransport interface
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/msgpack/rpc/transport/udp.rb', line 130 def listen(server) @server = server host, port = *@address.unpack io = UDPSocket.new io.bind(*@address) begin @sock = ServerSocket.new(io, @server) rescue io.close raise end begin @server.loop.attach(@sock) rescue @sock.close raise end end |