Class: Rev::TCPSocket::TCPConnectSocket

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of TCPConnectSocket.



152
153
154
155
156
157
158
159
160
161
# File 'lib/rev/socket.rb', line 152

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

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

Instance Method Details

#peeraddrObject



163
164
165
166
167
168
169
170
# File 'lib/rev/socket.rb', line 163

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