Feature #8897 » test.diff
test/socket/test_socket.rb | ||
---|---|---|
assert_instance_of(Socket::Ifaddr, ifaddr)
|
||
}
|
||
end
|
||
def test_tcp_fastopen
|
||
port = random_port
|
||
serv = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM)
|
||
serv.setsockopt(Socket::SOL_TCP, Socket::TCP_FASTOPEN, 5)
|
||
addrinfo = Addrinfo.new(Socket.sockaddr_in(port, "localhost"))
|
||
serv.bind(addrinfo)
|
||
serv.listen(1)
|
||
th = Thread.new do
|
||
sock, = serv.accept
|
||
begin
|
||
assert_equal("foo", sock.read)
|
||
ensure
|
||
sock.close if sock && !sock.closed?
|
||
end
|
||
end
|
||
sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM)
|
||
len = sock.send("foo", Socket::MSG_FASTOPEN, Socket.sockaddr_in(port, "localhost"))
|
||
assert_equal(len, 3)
|
||
sock.close
|
||
assert(th.join(10))
|
||
ensure
|
||
th.kill if th
|
||
sock.close if sock && !sock.closed?
|
||
end if defined?(Socket::TCP_FASTOPEN) && defined?(Socket::MSG_FASTOPEN)
|
||
end if defined?(Socket)
|
- « Previous
- 1
- 2
- Next »