Method: CMUX::Connection#open_port

Defined in:
lib/cmux/connection.rb

#open_port(index) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/cmux/connection.rb', line 50

def open_port(index)
  buffer = FFI::Buffer.new :pointer, 1
  status = Library.cmux_open_port @handle, index, buffer
  if status == -1
    raise Library.cmux_error(@handle)
  end

  pointer = buffer.read_pointer
  begin
    pointer.read_string
  ensure
    Library.cmux_free pointer
  end
end