Class List Method List File List

# Class: Vertx::NetClient

Inherits:
  Object
  - Object
  - Vertx::NetClient
  show all
Includes:
  SSLSupport, TCPSupport
Defined in:
  src/main/ruby_scripts/core/net.rb

## Overview

NetClient is an asynchronous factory for TCP or SSL connections. Multiple connections to different servers can be made using the same instance.

Author:

- Tim Fox

## Instance Method Summary (collapse)

- - (Object) close
  Close the NetClient.
- - (NetClient) connect(port, host = "localhost", proc = nil, &hndlr)
  Attempt to open a connection to a server.
- - (NetClient) initialize constructor
  Create a new NetClient.
- - (NetClient) trust_all=(val)
  Should the client trust ALL server certificates? against it's local client trust store.

### Methods included from SSLSupport

#key_store_password=, #key_store_path=, #ssl=, #trust_store_password=, #trust_store_path=

### Methods included from TCPSupport

#receive_buffer_size=, #reuse_address=, #send_buffer_size=, #so_linger=, #tcp_keep_alive=, #traffic_class=

## Constructor Details

### - (`NetClient`) initialize

Create a new NetClient

    84
    85
    86
    # File 'src/main/ruby_scripts/core/net.rb', line 84

    def initialize
      @j_del = org.vertx.java.deploy.impl.VertxLocator.vertx.createNetClient
    end

## Instance Method Details

### - (`Object`) close

Close the NetClient. Any open connections will be closed.

    112
    113
    114
    # File 'src/main/ruby_scripts/core/net.rb', line 112

    def close
      @j_del.close
    end

### - (`NetClient`) connect(port, host = "localhost", proc = nil, &hndlr)

Attempt to open a connection to a server. The connection is opened asynchronously and the result returned in the handler.

Parameters:

- port. (`FixNum`) —
  The port to connect to.
- host. (`String`) —
  The host or ip address to connect to.
- proc (`Proc`) (defaults to: `nil`) —
  A proc to be used as the handler
- hndlr (`Block`) —
  A block to be used as the handler

Returns:

- (`NetClient`) —
  A reference to self so invocations can be chained

    105
    106
    107
    108
    109
    # File 'src/main/ruby_scripts/core/net.rb', line 105

    def connect(port, host = "localhost", proc = nil, &hndlr)
      hndlr = proc if proc
      @j_del.connect(port, host) { |j_socket| hndlr.call(NetSocket.new(j_socket)) }
      self
    end

### - (`NetClient`) trust_all=(val)

Should the client trust ALL server certificates? against it's local client trust store. The default value is false. Use this method with caution!

Parameters:

- val. (`Boolean`) —
  If val is set to true then the client will trust ALL server certificates and will not attempt to authenticate them

Returns:

- (`NetClient`) —
  A reference to self so invocations can be chained

    93
    94
    95
    96
    # File 'src/main/ruby_scripts/core/net.rb', line 93

    def trust_all=(val)
      @j_del.setTrustAll(val)
      self
    end