Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/net/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3702,7 +3702,7 @@ def tcp_socket(host, port)
s = Socket.tcp(host, port, :connect_timeout => open_timeout)
s.setsockopt(:SOL_SOCKET, :SO_KEEPALIVE, true)
s
rescue Errno::ETIMEDOUT
rescue Errno::ETIMEDOUT, IO::TimeoutError
raise Net::OpenTimeout, "Timeout to open TCP connection to " +
"#{host}:#{port} (exceeds #{open_timeout} seconds)"
end
Expand Down
8 changes: 8 additions & 0 deletions test/net/imap/test_imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ class IMAPTest < Net::IMAP::TestCase
end
end

def test_open_timeout
host = ENV.fetch("TEST_OPEN_TIMEOUT_HOST", "10.255.255.1")
pend host if host.start_with? "skip"
assert_raise(Net::OpenTimeout) do
Net::IMAP.new(host, open_timeout: 0)
end
end

def test_unexpected_eof
server = create_tcp_server
port = server.addr[1]
Expand Down
Loading