lib/smb/client/client.rb
def connect
      # Run +@executable+ in a separate thread to talk to hin asynchronously
      Thread.start do
        # Spawn the actual +@executable+ pty with +input+ and +output+ handle
        begin
          PTY.spawn(@executable + ' ' + params) do |output, input, pid|
            @pid = pid
            output.sync = true
            input.sync = true

            # Write inputs to pty from +exec+ method
            Thread.start do
              while (line = @read1.readline)
                input.puts line
              end
            end

            # Wait for responses ending with input prompt
            loop do
              output.expect(/smb: \\>$/) { |text| handle_response text }
            end
          end
        rescue Errno::EIO => e
          unless @shutdown_in_progress
            if @connection_established
              raise StandardError, "Unexpected error: [#{e.message}]"
            else
              raise Client::ConnectionError, 'Cannot connect to SMB server'
            end
          end
        end
      end
    end
def connect
      # Run +@executable+ in a separate thread to talk to hin asynchronously
      Thread.start do
        # Spawn the actual +@executable+ pty with +input+ and +output+ handle
        begin
          PTY.spawn(@executable + ' ' + params) do |output, input, pid|
            @pid = pid
            output.sync = true
            input.sync = true

            # Write inputs to pty from +exec+ method
            Thread.start do
              while (line = @read1.readline)
                input.puts line
              end
            end

            # Wait for responses ending with input prompt
            loop do
              output.expect(/smb: \\>$/) { |text| handle_response text }
            end
          end
        rescue Errno::EIO => e
          unless @shutdown_in_progress
            if @connection_established
              raise StandardError, "Unexpected error: [#{e.message}]"
            else
              raise Client::ConnectionError, 'Cannot connect to SMB server'
            end
          end
        end
      end
    end
Connect to the server using separate threads and pipe for communications