2017 © Pedro Peláez
 

library socket

image

aysheka/socket

  • Thursday, April 24, 2014
  • by hushulin
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 11 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

This library provide functionality for working with socket

Notice: 1. Library was tested only on TCP, IP4, Stream connection 2. You can find samples(server, client) in test directory, (*1)

How connect to server

~~~~~ php <?php use Symfony\Component\EventDispatcher\EventDispatcher; use Aysheka\Socket\Client\Client; use Aysheka\Socket\Address\IP4; use Aysheka\Socket\Type\Stream; use Aysheka\Socket\Transport\TCP;, (*2)

$client = new Client('127.0.0.1', 8089, new IP4(), new Stream(), new TCP(), new EventDispatcher()); $client->connect(); $client->close();`, (*3)


And thats all How create a server ====================== ~~~~~ php use Aysheka\Socket\Client; use Aysheka\Socket\Type\Stream; use Symfony\Component\EventDispatcher\EventDispatcher; use Aysheka\Socket\Server\Event\NewConnectionEvent; use Aysheka\Socket\Server\Server; use Aysheka\Socket\Address\IP4; use Aysheka\Socket\Transport\TCP; $eventDispatcher = new EventDispatcher(); $eventDispatcher->addListener(NewConnectionEvent::getEventName(), function (NewConnectionEvent $event) { $socket = $event->getSocket(); $socket->write("HELLO I'm test server\n"); // Read bytes from socket if available while ($read = $socket->read()) { echo "Read data: [{$read}]"; $socket->write('Response'); usleep(50); } }); $server = new Server('127.0.0.1', 8089, new IP4(), new Stream(), new TCP(), $eventDispatcher); $server->create();

The Versions

24/04 2014

dev-master

9999999-dev

  Sources   Download

The Requires

 

The Development Requires

  • ext-pcntl *

02/03 2013

1.x-dev

1.9999999.9999999.9999999-dev

  Sources   Download

The Requires

 

The Development Requires

  • ext-pcntl *