I am writing a Usenet (NNTP) Class.
I'm connecting to the NNTP server using fsockopen() and retrieving the header info by simply sending:
// Send HEAD command to server
fputs($this -> pointer, "HEAD $message_id\n");
// Get first line of response to check response code
$tmp = split(" ", fgets($this -> pointer));
// If response code is 221 (article found), continue
If ($tmp[0] == "221") {
// Retrieve line by line, until end of output
while($buffer != ".\r\n") {
$buffer = fgets($this -> pointer);
// Store lines in array
$data[] = $buffer;
}
That works.
The problem I have is with the BODY of the Usenet Article. Since I am indexing BINARY articles, I only want the first 200 (or so) characters of the Article Body which gives me info about the filename, size, etc.
// Send BODY command to server
fputs($this -> pointer, "body $message_id\n");
while($buffer !=".\r\n") {
$buffer = fgets($this -> pointer);
echo $buffer;
}
This code streams the entire body (3000 lines!!!)... I only need the first 2 lines of characters... how can I LIMIT this?