/**
  * Callback for when server should be shut down
  *
  * @return vid
  */
 public static function shutdown()
 {
     $c = new Socket(self::$bindAddress[0], self::$bindAddress[1]);
     $c->connect();
     $c->write("HALT\n");
     $c->close();
 }
 /**
  * Callback for when server should be shut down
  */
 public static function shutdown()
 {
     $s = new Socket(self::$bindAddress[0], self::$bindAddress[1]);
     $s->connect();
     $s->write(pack('Nc4Na*', DEFAULT_PROTOCOL_MAGIC_NUMBER, 1, 0, 61, false, 0, null));
     $s->close();
 }
 /**
  * Connect to a socket. If socket still open from last request (which
  * is the case when unread data is left on it by not reading the body,
  * e.g.), use the quick & dirty way: Close and reopen!
  *
  * @param  peer.Socket $s
  * @param  double $read Read timeout
  * @param  double $connect Connect timeout
  * @return peer.Socket
  */
 protected function connect($s, $read, $connect)
 {
     $s->isConnected() && $s->close();
     $s->setTimeout($read);
     $s->connect($connect);
     return $s;
 }
 public static function shutdownServer()
 {
     // Tell the server to shut down
     try {
         $c = new Socket(self::$bindAddress[0], self::$bindAddress[1]);
         $c->connect();
         $c->write("HALT\n");
         $c->close();
     } catch (\lang\Throwable $ignored) {
         // Fall through, below should terminate the process anyway
     }
     $status = self::$serverProcess->out->readLine();
     if (!strlen($status) || '+' != $status[0]) {
         while ($l = self::$serverProcess->out->readLine()) {
             $status .= $l;
         }
         while ($l = self::$serverProcess->err->readLine()) {
             $status .= $l;
         }
         self::$serverProcess->close();
         throw new \lang\IllegalStateException($status);
     }
     self::$serverProcess->close();
 }