Module: OSC::VNC::Listenable
- Included in:
- Session
- Defined in:
- lib/osc/vnc/listenable.rb
Overview
Mixin that adds the ability to create and read from a TCP server.
Instance Method Summary collapse
-
#create_listen ⇒ TCPServer
Generate a TCP server that listens on a random port.
-
#read_listen(args) ⇒ String
Read the data received by the TCP server.
Instance Method Details
#create_listen ⇒ TCPServer
Generate a TCP server that listens on a random port.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/osc/vnc/listenable.rb', line 11 def create_listen listen_host = Socket.gethostname listen_port = _get_port begin server = TCPServer.new(listen_host, listen_port) rescue Errno::EADDRINUSE listen_port = _get_port retry end server end |
#read_listen(args) ⇒ String
Read the data received by the TCP server.
28 29 30 31 32 |
# File 'lib/osc/vnc/listenable.rb', line 28 def read_listen(args) server = args[:server] client = server.accept # wait for connection client.read # read complete response end |