Method: Networking::TCPClient#initialize

Defined in:
lib/networking/tcp.rb

#initialize(host, port, obj_clb = nil, reconnected_clb = nil) ⇒ TCPClient

Returns a new instance of TCPClient.



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/networking/tcp.rb', line 132

def initialize(host, port, obj_clb=nil, reconnected_clb=nil)
  @host = host
  @port = port
  @tcp_socket = nil
  @obj_clb = obj_clb
  @reconnected_clb = reconnected_clb
  # Variable to signal when remote server is ready.
  @remote_server_available = ConditionVariable.new
  @remote_server_available_mutex = Mutex.new
  Log.debug3("Start TCPClient initialize with @obj_clb: %s", @obj_clb)
  if @obj_clb != nil
    @tcp_thread = start_reading
    @tcp_thread.abort_on_exception = true
  end
  open_socket unless socket_good?
  Log.debug3("End TCPClient initialize.")
end