Class: EasySockets::TcpSocket

Inherits:
BasicSocket show all
Defined in:
lib/easy_sockets/tcp/tcp_socket.rb

Overview

Subclass of BasicSocket that implement a TCP socket.

Author:

  • Marcos Ortiz

Constant Summary

Constants inherited from BasicSocket

BasicSocket::DEFAULT_TIMEOUT

Instance Attribute Summary

Attributes inherited from BasicSocket

#connected, #logger

Instance Method Summary collapse

Methods inherited from BasicSocket

#connect, #disconnect, #send_msg

Methods included from Utils

#log

Constructor Details

#initialize(opts = {}) ⇒ TcpSocket

It also accepts all options that BasicSocket#initialize accepts

Parameters:

  • opts (Hash) (defaults to: {})

    the options to create a socket with.

Options Hash (opts):

  • :port (Integer) — default: 2000

    The tcp port the server is running on.

  • :host (String) — default: '127.0.0.1'

    The hostname or IP address the server is running on.



16
17
18
19
20
21
22
# File 'lib/easy_sockets/tcp/tcp_socket.rb', line 16

def initialize(opts={})
    super(opts)
    
    @port = opts[:port].to_i
    @port = DEFAULT_PORT if @port <= 0
    @host = opts[:host] || DEFAULT_HOST
end