Skip to content
StefansArya edited this page Jan 1, 2020 · 6 revisions

You may need to import this feature on top of your code.

use \Scarlets\Library\Socket;

create

This function will open new socket server that able
to process multiple request at the same time.

Socket::create($address, $port, $readCallback, $connectionCallback=0)

// Example
Socket::create('localhost', 8000, function($socketResource, $data){
    echo("Data received:");
    print_r($data);
}, function($socketResource, $status){
    echo("Someone $status");
});

simple

This function will open new socket server that able
to process single request at the a time.

Socket::simple($address, $port, $readCallback)

// Example
Socket::simple('localhost', 8000, function($socketResource, $data){
    echo("Data received:");
    print_r($data);
});

ping

Socket::ping($domain, $port=80)

getIPAddress

Get array of IP address that available on the current machine.

This function may be migrated to other library on the future.

Socket::getIPAddress();
Clone this wiki locally