39 protected $config = null;
46 protected $stream = null;
53 protected $adapter = null;
64 if(!array_key_exists(
"host", $config))
69 if(!array_key_exists(
"port", $config))
74 if(!array_key_exists(
"timeout", $config))
76 $config[
"timeout"] = 10;
79 if(!array_key_exists(
"blocking", $config))
81 $config[
"blocking"] = 1;
84 $this->config = $config;
94 return array(
"config");
116 $this->adapter->__destruct();
128 abstract public function connect();
144 abstract public function read($length = 4096);
152 abstract public function send($data);
161 return $this->stream;
175 return array_key_exists($key, $this->config) ? $this->config[$key] : $default;
178 return $this->config;
189 $this->adapter = $adapter;
199 return $this->adapter;
213 return $string->substr($string->findLast(
"_"))->replace(array(
"_",
" "),
"")->toString();
227 if($this->stream === null)
232 return stream_get_meta_data($this->stream);
242 return (is_resource($this->stream)) ? TRUE : FALSE;
254 if(!$this->
isConnected() || $this->config[
"blocking"])
return;
257 $read = array($this->stream);
265 $time = $time+$this->config[
"timeout"];
266 }
while(@stream_select($read, $null, $null, $this->config[
"timeout"]) == 0);