-
-
Notifications
You must be signed in to change notification settings - Fork 1
Socket
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;
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");
});
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);
});
Socket::ping($domain, $port=80)
Get array of IP address that available on the current machine.
This function may be migrated to other library on the future.
Socket::getIPAddress();