2017 © Pedro Peláez
 

library tcp-socket

TCP Socket for Laravel 5

image

isathais1/tcp-socket

TCP Socket for Laravel 5

  • Friday, April 13, 2018
  • by isathais1
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 1 Versions
  • 14 % Grown

The README.md

Laravel 5 TCP Socket

installation

For install this package Edit your project's composer.json file to require isathais1/tcp-socket, (*1)

"require": {
    "isathais1/tcp-socket": "dev-master"
},

Now, update Composer:, (*2)

composer update

Once composer is finished, you need to add the service provider. Open config/app.php, and add a new item to the providers array., (*3)

'isathais1\Socket\SocketServiceProvider',

Next, add a Facade for more convenient usage. In config/app.php add the following line to the aliases array:, (*4)

'Socket' => 'isathais1\Socket\Facades\Socket',

Publish config files:, (*5)

php artisan vendor:publish --provider="isathais1\Socket\SocketServiceProvider"

for change username, password and other configuration change config/tcp-socket.php, (*6)

Usage

Configuration

Open config/tcp-socket.phpbr/
Enter Server Ip Address and Port
You can change server protocol between SOL_TCP and SOL_UDP, (*7)

Connect To Server

Socket::connect();

Socket::connect($ip);
Socket::connect(null, $port);
Socket::connect($ip, $port);

Disconnect from Server

Socket::disconnect();

Send Message

Socket::sendMessage('test message'); //send message to connected server
Socket::sendMessageTo('test message', 'server ip', server port) // send message to a socket

Read Message

$response = Socket::readMessage(); //Read message with 2048 byte buffer

Or

$response = Socket::readMessage($length)//Read message with custom byte buffer;

$response = Socket::readMessage($length,$type)//Read message with custom byte buffer and custom type(PHP_NORMAL_READ or PHP_BINARY_READ);


The Versions

13/04 2018

dev-master

9999999-dev

TCP Socket for Laravel 5

  Sources   Download

MIT

The Requires

 

by Isa Thais