Class: Green::TCPServer

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

Constant Summary

Constants inherited from Socket

Socket::READ_BUFFER_SIZE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Socket

#connect, #kgio_wait_readable, #read, #recv, #send, #waiter, #write

Constructor Details

#initialize(host, port) ⇒ TCPServer

Returns a new instance of TCPServer.



107
108
109
110
111
112
113
# File 'lib/green/socket.rb', line 107

def initialize(host, port)
  addrinfo = Addrinfo.tcp(host, port)
  super(addrinfo.ipv4? ? :INET : :INET6, :STREAM, 0)
  setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, 1)
  bind(addrinfo)
  listen(5)
end

Class Method Details

.accept_socket_classObject



116
117
118
# File 'lib/green/socket.rb', line 116

def self.accept_socket_class
  TCPSocket
end

Instance Method Details

#acceptObject



120
121
122
# File 'lib/green/socket.rb', line 120

def accept
  super[0]
end