2004-12-06 03:15:56 -05:00
|
|
|
begin
|
|
|
|
require "socket"
|
|
|
|
require "test/unit"
|
|
|
|
rescue LoadError
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
class TestTCPSocket < Test::Unit::TestCase
|
2007-11-18 02:18:56 -05:00
|
|
|
def test_recvfrom
|
2007-09-01 03:27:26 -04:00
|
|
|
assert false, "TODO: doesn't work on mswin32/64" if /mswin/ =~ RUBY_PLATFORM
|
2004-12-06 03:15:56 -05:00
|
|
|
svr = TCPServer.new("localhost", 0)
|
2004-12-08 20:19:30 -05:00
|
|
|
th = Thread.new {
|
2004-12-07 13:26:12 -05:00
|
|
|
c = svr.accept
|
2008-07-23 10:25:32 -04:00
|
|
|
c.write "foo"
|
|
|
|
c.close
|
2004-12-06 03:15:56 -05:00
|
|
|
}
|
2004-12-07 18:35:18 -05:00
|
|
|
addr = svr.addr
|
|
|
|
sock = TCPSocket.open(addr[2], addr[1])
|
2008-07-23 10:25:32 -04:00
|
|
|
assert_equal(["foo", nil], sock.recvfrom(0x10000))
|
2004-12-08 20:19:30 -05:00
|
|
|
ensure
|
2008-07-23 10:25:32 -04:00
|
|
|
th.kill
|
2004-12-08 20:19:30 -05:00
|
|
|
th.join
|
2004-12-06 03:15:56 -05:00
|
|
|
end
|
|
|
|
end if defined?(TCPSocket)
|