class socketClient{
public $socketConnection;
public $Connection;
public $changed_sockets;
public function __construct($ipAddress,$port){
$this->socketConnection = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$this->Connection = socket_connect($this->socketConnection,$ipAddress, $port);
$this->changed_sockets = array($this->socketConnection);
}
public function sendMsg($msg){
socket_write($this->socketConnection, $msg);
}
public function recv(){
$num_changed_sockets = socket_select($this->changed_sockets, $write = NULL, $except = NULL, NULL);
foreach($this->changed_sockets as $socket) {
$bytes = @socket_recv($this->socketConnection, $buffer, 2048, 0);
return $buffer;
}
}
public function close(){
socket_close($this->socketConnection);
}
}