2007-10-19 04:31:34 -04:00
|
|
|
|
|
|
|
# Minimal test to help debug JRuby socket issues
|
|
|
|
|
2007-10-20 20:49:39 -04:00
|
|
|
require 'socket'
|
2007-10-20 22:27:56 -04:00
|
|
|
|
|
|
|
@server = Thread.new do
|
|
|
|
server_socket = TCPServer.new('0.0.0.0', 10101)
|
|
|
|
this_client = server_socket.accept
|
|
|
|
4.times do |n|
|
|
|
|
begin
|
2007-10-21 00:13:37 -04:00
|
|
|
data = this_client.readpartial(2)
|
2007-10-20 22:27:56 -04:00
|
|
|
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
|