This adds so_keepalive, tcp_keepidle, tcp_keepintvl and tcp_keepcnt
stream socket context options that are used to set their upper case
C macro variants by setsockopt function.
The test requires sockets extension and just tests that the values are
being set. This is because a real test would be slow and difficult to
show that those options really work due to how they work internally.
Closes GH-20381
SO_REUSEPORT on FreeBSD acts differently as the underlying semantic
is different (as it predates Linux) since it s more for UDP/multicasts.
The SO_REUSEPORT_LB flag, however, uses load balancing for group
of address:port combinations which is how Linux is implemented.
Co-authored-by: Jakub Zelenka <bukka@php.net>
This is to allow disabling of SO_REUSEADDR that is enabled by default.
To achieve better compatibility on Windows SO_EXCLUSIVEADDRUSE is set
if so_reuseaddr is false.
Closes GH-19967
Or on Windows it is going to use either FormatMessageW or strerror_s
for compatibility with previous error messages.
It also needs to accomodate for GNU and BSD versions of strerror_r
returning different type.
Closes GH-19251
When connecting to socket, it is possible to get EINTR. In such case,
there should be an another attempt to connect if we are not over the
timeout. The timeout should be adjusted accordingly in that case.
This fixes https://github.com/phpredis/phpredis/issues/1881
Closes GH-16606
First we refactor to have only a single usage of `PHP_GAI_STRERROR()`
left; then we drop the macro in favor of calling the different
functions conditionally in an ad-hoc style.
This is necessary because the return value of `php_win32_error_to_msg`
needs to be freed by the caller.
The error messages are no more inline with other error messages, since
`gai_strerror()` apparently always appends a period and a space.
We also properly configure IPv4/v6 on Windows. Since WSPiApi.h has been
created in 2000, so we can safely assume that it is available everywhere
nowadays. Furthermore, `gai_strerror()` is available regardless of
whether there is IPv6 support.
* main/network: Use more appropriate types
And check directly against 0 for success for functions not returning a zend_result
* Remove redundant declaration in file.h
Not sure why it even is here
* Mark many functions as static
Multiple functions are missing the static qualifier.
* remove unused struct sigactions
struct sigaction act, old_term, old_quit, old_int;
all unused.
* optimizer: minXOR and maxXOR are unused
Prior to the 8.1 rewrite, inet_aton was used for ipv4 addresses
therefore addresses like `0` passed.
For the bindto's case where both ip and port are set as such, we discard
the address binding.
Close GH-12195
When you choose to bind() to a local address and connect to a remote host
the kernel does not know if socket is listener or whatnot and has to reserve
a port within a ~32k range on which you are also competing with other
applications bound to the same address, this is easy to exhaust and get a
EADDRINUSE.
The linux kernel implemented IP_BIND_ADDRESS_NO_PORT on
90c337da15
which delays the port allocation until the 4-tuple is known in case source port
is 0.