amphp / socket

Non-blocking socket and TLS functionality for PHP based on Amp.
https://amphp.org/socket
MIT License
231 stars 38 forks source link

Support TCP keepalive option in BindContext #67

Open kelunik opened 5 years ago

bzikarsky commented 3 years ago

What about the ConnectContext? We have a client use-case that would profit from TCP keepalive (long-running HTTP 2.0 connections through a proxy that drops IDLE connections without keepalive)

I'd be open to provide a simple MR adding this to ConnectContext and BindContext. Implementation-wise we'd have a bit of an outlier because you cannot set tcp-keepalive in the stream-context array. Instead, we'd need to call socket_import_stream and socket_set_option on after stream_socket_server/stream_socket_client.

WDYT?

kelunik commented 3 years ago

We'll need to decide what to do if the socket extension isn't available then, ignore or error?

Otherwise same for Connect Context, yes.

For HTTP/2 you could also use pings at the application layer instead.