1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

jruby socket problem test

git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@709 19e92222-5c0b-0410-8929-a290d50e31e9
This commit is contained in:
evanweaver 2007-10-21 02:27:56 +00:00
parent 638620f70d
commit 0320048974
2 changed files with 37 additions and 4 deletions

View file

@ -2,7 +2,38 @@
# Minimal test to help debug JRuby socket issues
require 'socket'
socket = TCPSocket.new('127.0.0.1', '3000')
socket.write("G")
socket.close_write
socket.write("E")
@server = Thread.new do
server_socket = TCPServer.new('0.0.0.0', 10101)
this_client = server_socket.accept
4.times do |n|
begin
data = this_client.readpartial(4)
puts "Server got: #{data}"
if n == 0
this_client.close
puts "Server closed the client"
end
rescue IOError => e
puts "Server has: #{e.inspect}"
end
sleep(1)
end
server_socket.close
end
sleep(3)
client_socket = TCPSocket.new('0.0.0.0', 10101)
4.times do |n|
string = "X#{n}"
begin
client_socket.write(string)
puts "Client said: #{string}"
rescue Errno::EPIPE => e
puts "Client has: #{e.inspect}"
end
sleep(1)
end
client_socket.close
@server.join

View file

@ -48,9 +48,11 @@ class WebServerTest < Test::Unit::TestCase
@socket = TCPSocket.new("127.0.0.1", 9998);
request = StringIO.new(string)
chunks_out = 0
# STDERR.puts chunks_out
while data = request.read(chunk)
chunks_out += @socket.write(data)
# STDERR.puts chunks_out
@socket.flush
sleep 0.2
if close_after and chunks_out > close_after