/**
  * Sending request to oXD server via socket
  *
  * @param  string  $data
  * @param  int  $char_count
  * @return object
  */
 public function oxd_socket_request($data, $char_count = 8192)
 {
     if (!(self::$socket = stream_socket_client('127.0.0.1:' . Oxd_RP_config::$oxd_host_port, $errno, $errstr, STREAM_CLIENT_PERSISTENT))) {
         $this->log("Client: socket::socket_connect is not connected, error: ", $errstr);
         die($errno);
     } else {
         $this->log("Client: socket::socket_connect", "socket connected");
     }
     $this->log("Client: oxd_socket_request", fwrite(self::$socket, $data));
     fwrite(self::$socket, $data);
     $result = fread(self::$socket, $char_count);
     if ($result) {
         $this->log("Client: oxd_socket_response", $result);
     } else {
         $this->log("Client: oxd_socket_response", 'Error socket reading process.');
     }
     if (fclose(self::$socket)) {
         $this->log("Client: oxd_socket_connection", "disconnected.");
     }
     return $result;
 }
Пример #2
0
 /**
  * Constructor
  *
  * @return	void
  */
 public function __construct()
 {
     parent::__construct();
     // TODO: Change the autogenerated stub
     $this->setCommand();
     $exist = false;
     for ($i = 0; $i < count($this->command_types); $i++) {
         if ($this->command_types[$i] == $this->getCommand()) {
             $exist = true;
             break;
         }
     }
     if (!$exist) {
         $this->log('Command: ' . $this->getCommand() . ' is not exist!', 'Exiting process.');
         $this->error_message('Command: ' . $this->getCommand() . ' is not exist!');
     }
 }