Skip to content

[Feature #21347] Add open_timeout as an overall timeout option for TCPSocket.new#13909

Merged
shioimm merged 4 commits intoruby:masterfrom
shioimm:open_timeout-TCPSocket_new
Jul 17, 2025
Merged

[Feature #21347] Add open_timeout as an overall timeout option for TCPSocket.new#13909
shioimm merged 4 commits intoruby:masterfrom
shioimm:open_timeout-TCPSocket_new

Conversation

@shioimm
Copy link
Copy Markdown
Contributor

@shioimm shioimm commented Jul 16, 2025

With this change, TCPSocket.new now accepts the open_timeout option.
This option raises an exception if the specified number of seconds has elapsed since the start of the method call, even if the operation is still in the middle of name resolution or connection attempts.

The addition of this option follows the same intent as the previously merged change to Socket.tcp .
Feature #21347
#13368

shioimm added 2 commits July 16, 2025 21:03
…`TCPSocket.new`

With this change, `TCPSocket.new` now accepts the `open_timeout` option.
This option raises an exception if the specified number of seconds has elapsed since the start of the method call,
even if the operation is still in the middle of name resolution or connection attempts.

The addition of this option follows the same intent as the previously merged change to `Socket.tcp`.
[Feature #21347](https://bugs.ruby-lang.org/issues/21347)
ruby#13368
@shioimm shioimm force-pushed the open_timeout-TCPSocket_new branch from 7126eb6 to 636696f Compare July 16, 2025 12:04
@shioimm shioimm changed the title Add open_timeout as an overall timeout option for TCPSocket.new [Feature #21347] Add open_timeout as an overall timeout option for TCPSocket.new Jul 16, 2025
@launchable-app

This comment has been minimized.

Comment thread ext/socket/lib/socket.rb Outdated
# [:resolv_timeout] Specifies the timeout in seconds from when the hostname resolution starts.
# [:connect_timeout] This method sequentially attempts connecting to all candidate destination addresses.<br>The +connect_timeout+ specifies the timeout in seconds from the start of the connection attempt to the last candidate.<br>By default, all connection attempts continue until the timeout occurs.<br>When +fast_fallback:false+ is explicitly specified,<br>a timeout is set for each connection attempt and any connection attempt that exceeds its timeout will be canceled.
# [:open_timeout] Specifies the timeout in seconds from the start of the method execution.<br>If this timeout is reached while there are still addresses that have not yet been attempted for connection, no further attempts will be made.
# [:Specifies the timeout in seconds from the start of the method execution.<br>If this timeout is reached while there are still addresses that have not yet been attempted for connection, no further attempts will be made.<br>If this option is specified together with other timeout options, an +ArgumentError+ will be raised.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The head of the line ([:open_timeout] Specifies) is destroyed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing it out!

@shioimm shioimm merged commit ba49005 into ruby:master Jul 17, 2025
92 of 94 checks passed
@shioimm shioimm deleted the open_timeout-TCPSocket_new branch July 17, 2025 09:15
@osyoyu
Copy link
Copy Markdown
Contributor

osyoyu commented Jul 17, 2025

Super cool, thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants