Class: MessagePack::RPC::TCPServerTransport
- Inherits:
-
Object
- Object
- MessagePack::RPC::TCPServerTransport
- Defined in:
- lib/msgpack/rpc/transport/tcp.rb
Defined Under Namespace
Classes: ServerSocket
Instance Method Summary collapse
-
#close ⇒ Object
ServerTransport interface.
-
#initialize(address) ⇒ TCPServerTransport
constructor
A new instance of TCPServerTransport.
-
#listen(server) ⇒ Object
ServerTransport interface.
Constructor Details
#initialize(address) ⇒ TCPServerTransport
Returns a new instance of TCPServerTransport.
193 194 195 196 |
# File 'lib/msgpack/rpc/transport/tcp.rb', line 193 def initialize(address) @address = address @lsock = nil end |
Instance Method Details
#close ⇒ Object
ServerTransport interface
212 213 214 215 216 |
# File 'lib/msgpack/rpc/transport/tcp.rb', line 212 def close return unless @lsock @lsock.detach if @lsock.attached? @lsock.close end |
#listen(server) ⇒ Object
ServerTransport interface
199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/msgpack/rpc/transport/tcp.rb', line 199 def listen(server) @server = server host, port = *@address.unpack @lsock = Cool.io::TCPServer.new(host, port, ServerSocket, @server) begin @server.loop.attach(@lsock) rescue @lsock.close raise end end |