October 20th, 2000, 11:59 PM
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?
October 21st, 2000, 12:16 AM
Use it without a /length/ parameter. But, this just keeps reading everything until the EOF comes on.
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
October 21st, 2000, 12:27 AM
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).]