i m able to communicate using the imap functions in php and also using the openssl from commandline ,i just wanted to try this doing fsockopen() in php.
my code is : 

```
<?php

$sock=fsockopen('ssl://imap.gmail.com', '993',$errno, $errstr);
if(!$sock){
   echo $errstr;
}
else{
   fputs($sock,"a LOGIN user@gmail.com password\r\n");
   $out=fgets($sock,2000);
   fclose($sock);
   echo $out;
}

?>

```

the problem is i get just the first response from the server in $out

```
      * OK Gimap ready for requests from **.***.63.101 jj5if832612pbc.164 

```

and when i change the code with the while loop for fgets ,it keeps on loading and in the end time's out without showing anything.

```
  <?php

  $sock=fsockopen('ssl://imap.gmail.com', '993', $errno, $errstr);
  if(!$sock){
      echo $errstr;
  }
  else{
      fputs($sock,"a LOGIN user@gmail.com password\r\n");
      while(!feof($sock)){
      $out.=fgets($sock,2000);
      }
 fclose($sock);
 echo $out;
 }

 ?>

```

i want to see the reply of the server in $out after i fputs the login credentials.
i m able to view my emails from command line using openssl ,so i think the problem isnt my handling of imap .
maybe i m missing something basic about file streams .

thanks.