socket = @fsockopen($hostname, $port, $errno, $errstr, $timeout)) { socket_set_blocking($this->socket, 0); socket_set_timeout($this->socket, 31536000); return true; } else { $this->error = "{$errstr} (#{$errno}, ".__FILE__.", ".__LINE__.")"; return false; } } function socket_close() { return fclose($this->socket); } function socket_write($data) { return fwrite($this->socket, $data); } function socket_read($byte_count) { $mqr = get_magic_quotes_runtime(); set_magic_quotes_runtime(0); $buffer = fread($this->socket, $byte_count); set_magic_quotes_runtime($mqr); return $buffer; } } ?>