Class: Coolio::TCPSocket::TCPConnectSocket

Inherits:
Socket
  • Object
show all
Defined in:
lib/cool.io/socket.rb

Instance Method Summary collapse

Constructor Details

#initialize(family, addr, port, host = addr) ⇒ TCPConnectSocket

Returns a new instance of TCPConnectSocket.


161
162
163
164
165
166
167
168
169
170
# File 'lib/cool.io/socket.rb', line 161

def initialize(family, addr, port, host = addr)
  @host, @addr, @port = host, addr, port
  @address_family = nil

  super(family, ::Socket::SOCK_STREAM, 0)
  begin
    connect_nonblock(::Socket.sockaddr_in(port, addr))
  rescue Errno::EINPROGRESS
  end
end

Instance Method Details

#peeraddrObject


172
173
174
175
176
177
178
179
# File 'lib/cool.io/socket.rb', line 172

def peeraddr
  [
    @address_family == ::Socket::AF_INET ? 'AF_INET' : 'AF_INET6',
    @port,
    @host,
    @addr
  ]
end