Location: PHPKode > projects > Online Last.FM Player > class/socket.class.php
<?php

class lcs_fsocket {
	var $handle;
	var $connection;
	var $host;
	var $port;
	
	function lcs_fsocket ($host, $port) {
		$this->host = $host;
		$this->port = $port;
		
		if ( $this->handle = fsockopen($this->host, $this->port, $errno, $errdesc) ) {
			return TRUE;
		}
		else {
			die('Error');
			// return FALSE;
		}
	}
	
	function send ($msg) {
		fwrite($this->handle, $msg);
		$read = '';
   		while ( !feof($this->handle) ) {
       			$read .= fgets($this->handle, 128);
   		}
		return $read;
	}
	
	function close () {
		fclose($this->handle);
	}
}

?>
Return current item: Online Last.FM Player