System_Socket
[ class tree: System_Socket ] [ index: System_Socket ] [ all elements ]

Source for file unix-connection.php

Documentation is available at unix-connection.php

  1. <?php
  2.  
  3. /**
  4. * Simple unix socket connction
  5. * $Id: unix-connection.php,v 1.4 2004/04/25 16:31:19 mike Exp $
  6. */
  7. require_once 'System/Socket/Creator.php';
  8.  
  9. /**
  10. * Create the unix domain socket with the specified parameters passed through
  11. * to the underlying System_Socket.  Most of the used options are typical for
  12. * such a unix domain socket connection.
  13. * Note that unix domain sockets are not available on Win32.
  14. */
  15. $sock &System_Socket_Creator::createConnection(
  16.     array(  'proto'     => SOL_SOCKET,
  17.             'domain'    => AF_UNIX,
  18.             'type'      => SOCK_STREAM,
  19.             'address'   => '/tmp/pear.sock',
  20.             'port'      => 0,
  21.     )
  22. );
  23. /**
  24. * Alternatively:
  25. * <code>
  26. *   $sock = &System_Socket_Creator::createUnixConnection('/tmp/pear.sock');
  27. * </code>
  28. */
  29.  
  30. /**
  31. * Loop while we're connected
  32. */
  33. while($sock->hasSocket{
  34.     // echo kinda prompt
  35.     echo "\n>";
  36.     // read a line from STDIN
  37.     $line trim(fgets(STDIN));
  38.     // write the string through the socket connection
  39.     $sock->writeLine($line);
  40.     // if we catched an "exit" close our connection
  41.     if ($line == 'exit'{
  42.         $sock->close();
  43.         break;
  44.     }
  45. }
  46. ?>

Documentation generated on Mon, 11 Mar 2019 10:15:56 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.