PHP code example of maxfolder / unix_socket

1. Go to this page and download the library: Download maxfolder/unix_socket library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

maxfolder / unix_socket example snippets


 if (file_exists($settings['SOCK_FILE_PATH'])) {
      unlink($settings['SOCK_FILE_PATH']);
  }
  
  $server = (new ServerSocketDataBuilder())
      ->setDomainServerSocketFilePath($settings['SOCK_FILE_PATH'])
      ->setProtocolFamilyForSocket(AF_UNIX)
      ->setTypeOfDataExchange(SOCK_STREAM)
      ->setProtocol(0)
      ->setMaxByteForRead(65536)
      ->built();
  
  
  $server->run();


$client = (new ClientSocketDataBuilder())
    ->setDomainServerSocketFilePath($settings['SOCK_FILE_PATH'])
    ->setProtocolFamilyForSocket(AF_UNIX)
    ->setTypeOfDataExchange(SOCK_STREAM)
    ->setProtocol(0)
    ->setMaxByteForRead(65536)
    ->built();

$client->run();