2004-12-06 11:15:56 +03:00
|
|
|
begin
|
|
|
|
require "socket"
|
|
|
|
require "test/unit"
|
|
|
|
rescue LoadError
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
class TestTCPSocket < Test::Unit::TestCase
|
|
|
|
def test_recvfrom # [ruby-dev:24705]
|
2007-09-01 11:27:26 +04:00
|
|
|
assert false, "TODO: doesn't work on mswin32/64" if /mswin/ =~ RUBY_PLATFORM
|
2004-12-07 21:26:12 +03:00
|
|
|
c = s = nil
|
2004-12-06 11:15:56 +03:00
|
|
|
svr = TCPServer.new("localhost", 0)
|
2004-12-09 04:19:30 +03:00
|
|
|
th = Thread.new {
|
2004-12-07 21:26:12 +03:00
|
|
|
c = svr.accept
|
2005-09-16 07:09:51 +04:00
|
|
|
Thread.pass
|
2004-12-06 11:15:56 +03:00
|
|
|
ObjectSpace.each_object(String) {|s|
|
2004-12-07 21:26:12 +03:00
|
|
|
s.replace "a" if s.length == 0x10000 and !s.frozen?
|
2004-12-06 11:15:56 +03:00
|
|
|
}
|
2005-09-17 18:40:06 +04:00
|
|
|
c.print("x"*0x1000)
|
2004-12-06 11:15:56 +03:00
|
|
|
}
|
2004-12-08 02:35:18 +03:00
|
|
|
addr = svr.addr
|
|
|
|
sock = TCPSocket.open(addr[2], addr[1])
|
2004-12-07 02:02:17 +03:00
|
|
|
assert_raise(RuntimeError, SocketError) {
|
2005-09-17 18:40:06 +04:00
|
|
|
sock.recvfrom(0x10000)
|
2004-12-06 18:31:26 +03:00
|
|
|
}
|
2004-12-09 04:19:30 +03:00
|
|
|
ensure
|
|
|
|
th.join
|
2004-12-06 11:15:56 +03:00
|
|
|
end
|
|
|
|
end if defined?(TCPSocket)
|