Download the PHP package edefimov/async-sockets without Composer
On this page you can find all versions of the php package edefimov/async-sockets. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download edefimov/async-sockets
More information about edefimov/async-sockets
Files in edefimov/async-sockets
Package async-sockets
Short Description Library for asynchronous work with sockets based on php streams
License MIT
Homepage https://github.com/edefimov/async-sockets
Informations about the package async-sockets
Async sockets library
Async sockets is event-based library for asynchronous work with sockets built on php streams.
Features
- multiple requests execution at once
- distinguish frame boundaries
- server socket support
- persistent connections support
- multiple persistent connections to the same host:port
- processing TLS handshake asynchronous
- synchronization between sockets
- determine datagram size for UDP sockets
- all transports returned by stream_get_transports are supported
- compatible with symfony event dispatcher component
- full control over timeouts
- dynamically adding new request during execution process
- separate timeout values for each socket
- custom sockets setup by php stream contexts
- custom user context for each socket
- stop request either for certain socket or for all of them
- strategies for limiting number of running requests
- error handling is based on exceptions
- supports libevent engine
What is it for
Async sockets library provides networking layer for applications, hides complexity of I/O operations, and cares about connections management. The library will be a powerful base for implementing arbitrary networking protocol as for implementing server on PHP. Running multiple requests at once decreases delay of I/O operation to the size of timeout assigned to the slowest server.
Documentation
Installation
The recommended way to install async sockets library is through composer
stable version:
actual version:
Use --prefer-dist
option in production environment, so as it ignores downloading of test and demo files,
and --prefer-source
option for development. Development version includes both test and demo files.
Quick start
Step 1. Create AsyncSocketFactory
at point where you want to start request
Step 2. Create RequestExecutor and proper amount of sockets
Step 3. Create event handler with events, you are interested in
Step 4. Add sockets into RequestExecutor
Step 5. Execute it!
Example usage
Client socket
See full example here
Server socket
See full example here