Skip to content

Collection of classes for server and client to connect via non blocking sockets

Notifications You must be signed in to change notification settings

Adam7288/php-nonblocking-sockets-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Collection of classes for server and client to connect via non blocking sockets.

Server Usage

  try {
    $socketServer = new ServerSocket($port, $handleRequest);
  } catch (Exception $e) {
     //exception handling
  }
  while(true) {

    $socketServer->checkForIncoming(.1);
    $socketServer->readAndWrite(.1);

    //do stuff
  }

Client Usage

    try { 
      $connection = new ClientSocket('localhost', $serverPort, 10);
    } catch(Exception $e) {
      //exception handling
    }

    $connection->setWaitTimeout($timeout);
    $sendResult = $connection->sendRequest(json_encode($data));

    if($sendResult === false) {

      $connection->closeConn();
      return false;
    }

    $reply = $connection->getReply();
    $connection->closeConn();

About

Collection of classes for server and client to connect via non blocking sockets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages