Class: Contrast::Api::Communication::TcpSocket

Inherits:
Object
  • Object
show all
Includes:
Socket
Defined in:
lib/contrast/api/communication/tcp_socket.rb

Overview

This class allows us to create a TCP Socket to communicate to the Service (Speed Racer). Either it or the Unix Socket will be used, as determined by the configuration options set for Service communication.

Constant Summary

Constants included from Socket

Socket::SOCKET_MONITOR

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Socket

#send_marshaled

Constructor Details

#initialize(host, port) ⇒ TcpSocket

Create the socket

Parameters:

  • host (String)

    socket target hostname or IP address

  • port (String, Integer)

    socket target port



20
21
22
23
# File 'lib/contrast/api/communication/tcp_socket.rb', line 20

def initialize host, port
  @host = host.to_s
  @port = port.to_i
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



15
16
17
# File 'lib/contrast/api/communication/tcp_socket.rb', line 15

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



15
16
17
# File 'lib/contrast/api/communication/tcp_socket.rb', line 15

def port
  @port
end

Instance Method Details

#new_socketObject



25
26
27
# File 'lib/contrast/api/communication/tcp_socket.rb', line 25

def new_socket
  ::TCPSocket.new(host, port)
end