-
Notifications
You must be signed in to change notification settings - Fork 8k
ext/sockets: adding Linux's TCP_USER_TIMEOUT constant. #20708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
d87015f
67ee0ad
1117658
1cd17b1
a804258
840e546
efb6560
66a4ea4
dab9d20
691fa14
1f9ce74
51cac49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| --TEST-- | ||
| Test if socket_set_option() works, option:TCP_USER_TIMEOUT | ||
| --EXTENSIONS-- | ||
| sockets | ||
| --SKIPIF-- | ||
| <?php | ||
| if (!defined('TCP_USER_TIMEOUT')) { die('skip TCP_USER_TIMEOUT is not defined'); } | ||
| ?> | ||
| --FILE-- | ||
| <?php | ||
| $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); | ||
| if (!$socket) { | ||
| die('Unable to create AF_INET socket [socket]'); | ||
| } | ||
| socket_set_block($socket); | ||
|
|
||
| try { | ||
| socket_setopt($socket, SOL_TCP, TCP_USER_TIMEOUT, -1); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: now I see it s working, please add a test with a large number (e.g. PHP_INT_MAX)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. after that, that will be all :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do I account for differences in 32-bit and 64-bit PHP versions. PHP_INT_MAX will be less than UINT_MAX on 32-bit versions UINT_MAX 4294967295 I know we can test for PHP_INT_MAX = 4 and skip the check, however unsure how I would then handle the missing output in 32-bit EXPECTF (seperate test case?)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that s a good point there is the possibility to create two tests one for 32 and for 64 bits indeed. |
||
| } catch (\ValueError $e) { | ||
| echo $e->getMessage(), PHP_EOL; | ||
| } | ||
|
|
||
| $timeout = 200; | ||
| $retval_2 = socket_set_option($socket, SOL_TCP, TCP_USER_TIMEOUT, $timeout); | ||
| $retval_3 = socket_get_option($socket, SOL_TCP, TCP_USER_TIMEOUT); | ||
| var_dump($retval_2); | ||
| var_dump($retval_3 === $timeout); | ||
| socket_close($socket); | ||
| ?> | ||
| --EXPECTF-- | ||
| socket_setopt(): Argument #4 ($value) must be of between 0 and %d | ||
| bool(true) | ||
| bool(true) | ||
Uh oh!
There was an error while loading. Please reload this page.