Download the PHP package rtm-ctrlz/keepalive without Composer

On this page you can find all versions of the php package rtm-ctrlz/keepalive. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package keepalive

Keepalive

This is a helper for setting proper TCP-Keepalive options and values.

Reason

Common way to enable TCP-Keepalive on a socket looks like this:

And yes, it enables keepalive, but what are keepalive parameters? Example above will use system-default values!

Most systems (OSes) have the following defaults:

Option Default value Description
SO_KEEPALIVE 0 TCP Keep-Alive is disabled
TCP_KEEPIDLE 7200 Start keepalive probes after this period (2 hours)
TCP_KEEPINTVL 75 Interval between keepalive probes (75 seconds)
TCP_KEEPCNT 8 Number of keepalive probes before death

So, with default values, first TCP-Keepalive packet will be sent only in 2 hours after last packet, then wait more up to 10 minutes (75s * 8) before dropping dead connection.

Is this really your case?

Not for me, I'd like drop connection within 1 minute or less!

Install

Usage

Below you can find some examples (socket/stream/ssl-stream) for "client-side", but same operations could be done for "server-side".

In examples below we use following parameters:

So we'd get maximum waiting time of 1 minute.

Raw sockets

Streams (tcp)

Streams (ssl)

This will be a bit harder, because socket_import_stream can not import socket.

But we can do a trick:

More examples

See examples directory for more examples.

Gotchas

Option numbers

Unfortunately PHP (and ext-sockets) doesn't have TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT constants.

Found values

Option Linux Darwin BSD
TCP_KEEPIDLE 4 16 256
TCP_KEEPINTVL 5 257 512
TCP_KEEPCNT 6 258 1024

Linux: Linux tcp.h Darwin: Darwin XNU tcp.h BSD: FreeBSD tcp.h

Windows support

Well, Windows should have support for TCP-Keepalive options, but:

Feel free to make a PR ;)

Tested with


All versions of keepalive with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2 || ^8.0
ext-sockets Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rtm-ctrlz/keepalive contains the following files

Loading the files please wait ....