src/lastfmapi/Lib/Socket.php
function send($msg, $type = '')
    {
        // Set a short timeout to prevent long hangs
        stream_set_timeout($this->handle, 2);
        // Send message over connection
        fwrite($this->handle, $msg);

        // Check what type is required
        if ($type == 'array') {
            // If array loop and create array
            $response = array();
            $line_num = 0;
            while (!feof($this->handle)) {
                if (($response[$line_num] = fgets($this->handle, 4096)) === false) {
                    break;
                } else {
                    $line_num++;
                }
            }
            // Return response as array
            return $response;
        } elseif ($type == 'string') {
            // If string, loop and create string
            $response = '';
            while (!feof($this->handle)) {
                $response .= fgets($this->handle, 4096);
            }
            // Return response as string
            return $response;
        } else {
            // If anything else, return nothing but a true
            return true;
        }
    }
function send($msg, $type = '')
    {
        // Set a short timeout to prevent long hangs
        stream_set_timeout($this->handle, 2);
        // Send message over connection
        fwrite($this->handle, $msg);

        // Check what type is required
        if ($type == 'array') {
            // If array loop and create array
            $response = array();
            $line_num = 0;
            while (!feof($this->handle)) {
                if (($response[$line_num] = fgets($this->handle, 4096)) === false) {
                    break;
                } else {
                    $line_num++;
                }
            }
            // Return response as array
            return $response;
        } elseif ($type == 'string') {
            // If string, loop and create string
            $response = '';
            while (!feof($this->handle)) {
                $response .= fgets($this->handle, 4096);
            }
            // Return response as string
            return $response;
        } else {
            // If anything else, return nothing but a true
            return true;
        }
    }
function send ( $ msg , $ type = '' ) { // Set a short timeout to prevent long hangs
 stream_set_timeout ( $ this -> handle , 2 ) ; // Send message over connection
 fwrite ( $ this -> handle , $ msg ) ; // Check what type is required
 if ( $ type == 'array' ) { // If array loop and create array
 $ response = array ( ) ; $ line_num = 0 ; while ( ! feof ( $ this -> handle ) ) { if ( ( $ response [ $ line_num ] = fgets ( $ this -> handle , 4096 ) ) === false ) { break ; } else { $ line_num ++ ; } } // Return response as array
 return $ response ; } elseif ( $ type == 'string' ) { // If string, loop and create string
 $ response = '' ; while ( ! feof ( $ this -> handle ) ) { $ response .= fgets ( $ this -> handle , 4096 ) ; } // Return response as string
 return $ response ; } else { // If anything else, return nothing but a true
 return true ; } }
Send data through the socket and listen for a return
@param string $msg Data to send
@param string $type The type of data to return (array or string)
@return string|array
Send data through the socket and listen for a return