2017 © Pedro Peláez
 

library php-socket-emitter

Sends data over a TCP socket in an efficient manner

image

danjohnson95/php-socket-emitter

Sends data over a TCP socket in an efficient manner

  • Tuesday, February 14, 2017
  • by danjohnson95
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PHP-Socket-Emitter

Sends data over a TCP socket in an efficient manner, (*1)

Installation

$ composer require danjohnson95/php-socket-emitter

Usage

$host = "192.168.0.3"; // Where the TCP socket server is hosted
$port = 3010; // The port in which the TCP socket server is running on
$Socket = new Danj\PHPSocketEmitter\Socket($host, $port);

$Socket->send([
    'any'  => 'data',
    'you'  => 'want',
    'to'   => 'send',
    'goes' => 'here!'
]);

Why do I need this?

Due to the asyncronous nature of PHP, you can't send lots of sockets over a short period of time., (*2)

This is because PHP can't tell if the last one has finished sending, and you can't send another TCP socket until the last one was received., (*3)

PHP-Socket-Emitter stores when the last socket was sent, and will delay execution of sending more until we can reasonably assume the last one was sent., (*4)

Therefore, you can do stuff like this:, (*5)

foreach($BigObject as $Bit){
    $Socket->send($Array);
}

The Versions

14/02 2017

dev-master

9999999-dev

Sends data over a TCP socket in an efficient manner

  Sources   Download