hello i am connecting to a POP3 server and want to read all the data recived into a variable

as you prolly know fgets() only retrives 1 line of data so i made this loop, but when it executes it hits an infinate loop

PHP Code:
while (!feof ($fd)) {

    
$buffer fgets($fd4096);

    echo 
$buffer;


obiously not good

how can i do this since it says socket_read() is not defined on my hosting server but fsockopen() works fine

thanks for ya help