Class: EventMachine::EvmaUNIXServer
- Inherits:
-
Selectable
- Object
- Selectable
- EventMachine::EvmaUNIXServer
- Defined in:
- lib/pr_eventmachine.rb
Instance Attribute Summary
Attributes inherited from Selectable
Class Method Summary collapse
-
.start_server(chain) ⇒ Object
Versions of ruby 1.8.4 later than May 26 2006 will work properly with an object of type TCPServer.
Instance Method Summary collapse
-
#eventable_read ⇒ Object
– accept_nonblock returns an array consisting of the accepted socket and a sockaddr_in which names the peer.
-
#initialize(io) ⇒ EvmaUNIXServer
constructor
A new instance of EvmaUNIXServer.
-
#schedule_close ⇒ Object
–.
- #select_for_reading? ⇒ Boolean
Methods inherited from Selectable
#close_scheduled?, #get_peername, #heartbeat, #select_for_writing?, #set_inactivity_timeout
Constructor Details
#initialize(io) ⇒ EvmaUNIXServer
Returns a new instance of EvmaUNIXServer.
852 853 854 |
# File 'lib/pr_eventmachine.rb', line 852 def initialize io super io end |
Class Method Details
.start_server(chain) ⇒ Object
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.
843 844 845 846 847 848 849 |
# File 'lib/pr_eventmachine.rb', line 843 def start_server chain sd = Socket.new( Socket::AF_LOCAL, Socket::SOCK_STREAM, 0 ) sd.setsockopt( Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true ) sd.bind( Socket.pack_sockaddr_un( chain )) sd.listen( 50 ) # 5 is what you see in all the books. Ain't enough. EvmaUNIXServer.new sd end |
Instance Method Details
#eventable_read ⇒ Object
– accept_nonblock returns an array consisting of the accepted socket and a sockaddr_in which names the peer. Don’t accept more than 10 at a time.
865 866 867 868 869 870 871 872 873 874 |
# File 'lib/pr_eventmachine.rb', line 865 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 ⇒ Object
–
878 879 880 |
# File 'lib/pr_eventmachine.rb', line 878 def schedule_close @close_scheduled = true end |
#select_for_reading? ⇒ Boolean
857 858 859 |
# File 'lib/pr_eventmachine.rb', line 857 def select_for_reading? true end |