Path: | lib/poll.rb |
Last Update: | Mon Oct 21 03:47:01 +0000 2002 |
An object-oriented implementation of poll(2) for Ruby
require 'poll' require 'socket' pollobj = Poll::new sock = TCPServer::new('localhost', 1138) pollobj.register( sock, Poll::RDNORM ) {|sock,evmask| case evmask when Poll::RDNORM clsock = sock.accept pollobj.mask( clsock, Poll::RDNORM, clientHandler ) when Poll::HUP|Poll::ERR|Poll::NVAL pollobj.remove( io ) $stderr.puts "Server error: Shutting down" else $stderr.puts "Unhandled event: #{evmask}" end } pollobj.poll( 0.25 ) until poll.handles.empty?
Michael Granger <ged@FaerieMUD.org>
Copyright (c) 2002 The FaerieMUD Consortium. All rights reserved.
This module is free software. You may use, modify, and/or redistribute this software under the same terms as Ruby itself.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$Id: poll.rb,v 1.10 2002/10/21 03:47:01 deveiant Exp $