Class: Green::TCPServer
Constant Summary
Constants inherited from Socket
Class Method Summary collapse
Instance Method Summary collapse
- #accept ⇒ Object
-
#initialize(host, port) ⇒ TCPServer
constructor
A new instance of TCPServer.
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_class ⇒ Object
116 117 118 |
# File 'lib/green/socket.rb', line 116 def self.accept_socket_class TCPSocket end |
Instance Method Details
#accept ⇒ Object
120 121 122 |
# File 'lib/green/socket.rb', line 120 def accept super[0] end |