#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Melbourne, Victoria, Australia
    Posts
    104
    Rep Power
    15
    Firstly thankyou in advance to anyone who responds.

    I have a socket open (opened with fsockopen()) and I'm sending pop3 requests over it. When I use fread() to get the response of the pop server, there's the possibility that the response can be of length anywhere between 1 character and several million (obvious reasons).

    Does anyone know if there's a way to read the entire incoming data when you don't know the length of it, without putting in some rediculously large number into fread's length parameter?

    Thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Ontario, Canada
    Posts
    498
    Rep Power
    18
    Use it without a /length/ parameter. But, this just keeps reading everything until the EOF comes on.

    ex;

    fread("somefile.txt"); // this will read the entire file until it hits the EOF.

    ------------------
    To alcohol! The cause of, and solution to, all of life's problems. -- Homer Simpson
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Melbourne, Victoria, Australia
    Posts
    104
    Rep Power
    15
    I removed the length parameter and it errored saying wrong parameter count (what I expected)


    Oh by the way I meant to say I'm using fgets() not fread, because if I try to fread() more characters then are returned it just hangs while waiting for more to come in over the socket, which of course never happens.


    I'm going to try retrieving say 1000 bytes a time then testing for eof using feof() then trieving another 1000 etc

    Please advise me if i'm going about this all wrong

    [This message has been edited by #6 (edited October 20, 2000).]

Similar Threads

  1. layout ideas and suggestions
    By knera in forum Website Critiques
    Replies: 2
    Last Post: January 18th, 2004, 12:20 AM
  2. lookin for web logon ideas
    By robla in forum Beginner Programming
    Replies: 7
    Last Post: December 19th, 2003, 02:32 PM
  3. Any ideas to compress a set of integers
    By nweena in forum C Programming
    Replies: 1
    Last Post: November 4th, 2003, 06:08 PM
  4. Plan to start new site(s) - Here are some ideas
    By newsgeek in forum Beginner Programming
    Replies: 3
    Last Post: September 21st, 2003, 06:45 AM
  5. Replies: 2
    Last Post: September 10th, 2003, 11:59 PM

IMN logo majestic logo threadwatch logo seochat tools logo