fsock problem - please help!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts

  • John Downey
    Guest replied
    Re: fsock problem - please help!

    Alan Little wrote:[color=blue]
    > Carved in mystic runes upon the very living rock, the last words of
    > Steve Macleod of comp.lang.php make plain:
    >
    >[color=green]
    >>Im having a problem with an (apparently) simple little script, which
    >>is designed to log on to a POP3 server and list the number of emails.
    >>I can log in with username and password, and can relay the server
    >>echos back to the page, but run into problems when I attempt to set up
    >>a while loop to read more than one line of repsonse from the server.
    >>
    >>My code looks like this:
    >>
    >>
    >>fputs ($server_connec t, "LIST \n\n");[/color]
    >
    >
    > First of all, there should be no space, and only one newline after LIST.
    > I don't know that the space hurts anything, but it doesn't belong there.
    >
    >[color=green]
    >>while (!feof($server_ connect)) {[/color]
    >
    >
    > The server's responses end with a period by itself on a line. Check for
    > that instead of eof.
    >[/color]
    throw a call to flush() in there after the echos or turn
    ob_implicit_flu sh() on so PHP will send what it has to the browser
    instead of waiting for you to end the page.

    --
    John Downey




    Leave a comment:


  • Alan Little
    Guest replied
    Re: fsock problem - please help!

    Carved in mystic runes upon the very living rock, the last words of Alan
    Little of comp.lang.php make plain:
    [color=blue]
    > The server's responses end with a period by itself on a line. Check
    > for that instead of eof.[/color]

    Actually, that's inaccurate. Multi-line responses end with a period by
    itself. Some responses (to a STAT command, for example) are just one line.
    For more info, refer to the POP3 RFC (if you haven't already):

    ftp://ftp.rfc-editor.org/in-notes/rfc1939.txt

    There's a great example POP session near the end of the document.

    --
    Alan Little
    Phorm PHP Form Processor

    Leave a comment:


  • Alan Little
    Guest replied
    Re: fsock problem - please help!

    Carved in mystic runes upon the very living rock, the last words of
    Steve Macleod of comp.lang.php make plain:
    [color=blue]
    > Im having a problem with an (apparently) simple little script, which
    > is designed to log on to a POP3 server and list the number of emails.
    > I can log in with username and password, and can relay the server
    > echos back to the page, but run into problems when I attempt to set up
    > a while loop to read more than one line of repsonse from the server.
    >
    > My code looks like this:
    >
    >
    > fputs ($server_connec t, "LIST \n\n");[/color]

    First of all, there should be no space, and only one newline after LIST.
    I don't know that the space hurts anything, but it doesn't belong there.
    [color=blue]
    > while (!feof($server_ connect)) {[/color]

    The server's responses end with a period by itself on a line. Check for
    that instead of eof.

    --
    Alan Little
    Phorm PHP Form Processor

    Leave a comment:


  • Steve Macleod
    Guest started a topic fsock problem - please help!

    fsock problem - please help!

    Hi,

    Im having a problem with an (apparently) simple little script, which is
    designed to log on to a POP3 server and list the number of emails. I can log
    in with username and password, and can relay the server echos back to the
    page, but run into problems when I attempt to set up a while loop to read
    more than one line of repsonse from the server.

    My code looks like this:


    fputs ($server_connec t, "LIST \n\n");

    while (!feof($server_ connect)) {
    echo fgets ($server_connec t,255);
    echo "<br>";
    }
    fclose ($server_connec t);


    $server_connect is an instance of the fsockopen() function. I keep getting
    the appropirate output from this code, but only once the page has timed out!

    Does anyone know how I could go about fixing this, so that I capture all
    output from the server, but dont have to wait for a timeout to see the data.

    Thanks.





Working...