class Byebug::Remote::Server - byebug-11.0.1 Documentation

# class Byebug::Remote::Server

Server for remote debugging

### Attributes

actual_port[R]
wait_connection[R]

### Public Class Methods

new(wait_connection:, &block) click to toggle source

    # File lib/byebug/remote/server.rb, line 13
    def initialize(wait_connection:, &block)
      @thread = nil
      @wait_connection = wait_connection
      @main_loop = block
    end

### Public Instance Methods

start(host, port) { || ... } click to toggle source

Start the remote debugging server

    # File lib/byebug/remote/server.rb, line 22
    def start(host, port)
      return if @thread

      if wait_connection
        mutex = Mutex.new
        proceed = ConditionVariable.new
      end

      server = TCPServer.new(host, port)
      @actual_port = server.addr[1]

      yield if block_given?

      @thread = DebugThread.new do
        while (session = server.accept)
          @main_loop.call(session)

          mutex.synchronize { proceed.signal } if wait_connection
        end
      end

      mutex.synchronize { proceed.wait(mutex) } if wait_connection
    end