class EventMachine::EvmaTCPServer

@private

Public Class Methods

new(io) click to toggle source
Calls superclass method EventMachine::Selectable.new
# File lib/em/pure_ruby.rb, line 795
def initialize io
  super io
end
start_server(host, port) click to toggle source

Versions of ruby 1.8.4 later than May 26 2006 will work properly with an object of type TCPServer. Prior versions won't so we play it safe and just build a socket.

# File lib/em/pure_ruby.rb, line 786
def start_server host, port
  sd = Socket.new( Socket::AF_INET, Socket::SOCK_STREAM, 0 )
  sd.setsockopt( Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true )
  sd.bind( Socket.pack_sockaddr_in( port, host ))
  sd.listen( 50 ) # 5 is what you see in all the books. Ain't enough.
  EvmaTCPServer.new sd
end

Public Instance Methods

eventable_read() click to toggle source
# File lib/em/pure_ruby.rb, line 808
def eventable_read
  begin
    10.times {
      descriptor,peername = io.accept_nonblock
      sd = StreamObject.new descriptor
      EventMachine::event_callback uuid, ConnectionAccepted, sd.uuid
    }
  rescue Errno::EWOULDBLOCK, Errno::EAGAIN
  end
end
schedule_close() click to toggle source
# File lib/em/pure_ruby.rb, line 821
def schedule_close
  @close_scheduled = true
end
select_for_reading?() click to toggle source
# File lib/em/pure_ruby.rb, line 800
def select_for_reading?
  true
end