Skip to content

Instantly share code, notes, and snippets.

@iconoclast
Created October 25, 2012 01:13
Show Gist options
  • Save iconoclast/3949918 to your computer and use it in GitHub Desktop.
Save iconoclast/3949918 to your computer and use it in GitHub Desktop.
Test for IO.select bug as seen with jruby on aix
## simple test to check for broken IO.select behavior as seen with jruby on aix using java6 or java7
##
require 'socket'
begin
port = ARGV.shift || '4321'
server = TCPServer.new('localhost', port)
client = TCPSocket.new('localhost', port)
sock = server.accept
readables, writeables, errors = IO.select([sock], [sock], [sock], 0)
# At this point there shouldn't be anything on the socket for us to read
fail 'IO.select seems to be broken for this system!' if (readables && readables.any?)
puts 'It appears that IO.select may be functioning correctly on this system'
ensure
server.close if server
client.close if client
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment