Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.2

Request #14181 \r\n vs \n
Submitted: 2008-06-18 19:49 UTC
From: lampacz Assigned: chagenbu
Status: Closed Package: Net_Socket (version 1.0.8)
PHP Version: 5.2.5 OS: ANY
Roadmaps: (Not assigned)    
Subscription  


 [2008-06-18 19:49 UTC] lampacz (Michal Dvoracek)
Description: ------------ good be to select trainling characters to append in writeLine. Default is \r\n which is not in every case good.

Comments

 [2008-06-19 20:11 UTC] lampacz (Michal Dvoracek)
i made patch. is acceptable ? --- Socket.php 2008-05-03 21:58:10.000000000 +0200 +++ Socket_new.php 2008-06-19 22:05:34.000000000 +0200 @@ -78,6 +78,8 @@ */ var $lineLength = 2048; + var $trailing = "\r\n"; + /** * Connect to the specified port. If called when the socket is * already connected, it disconnects and connects again. @@ -165,6 +167,15 @@ return true; } + function getTrailing() { + return $this->trailing; + } + + function setTrailing($trailing) { + $this->trailing = $trailing; + return true; + } + /** * Find out if the socket is in blocking mode. * @@ -333,7 +344,7 @@ } /** - * Write a line of data to the socket, followed by a trailing "\r\n". + * Write a line of data to the socket, followed by a trailing $this->trailing. * * @access public * @return mixed fputs result, or an error @@ -344,7 +355,7 @@ return $this->raiseError('not connected'); } - return fwrite($this->fp, $data . "\r\n"); + return fwrite($this->fp, $data . $this->trailing); } /** @@ -469,7 +480,7 @@ while (!feof($this->fp) && (!$this->timeout || time() < $timeout)) { $line .= @fgets($this->fp, $this->lineLength); if (substr($line, -1) == "\n") { - return rtrim($line, "\r\n"); + return rtrim($line, $this->trailing); } } return $line; trailing characters are selectable by setTrailing (default is \r\n)
 [2008-12-01 17:26 UTC] chagenbu (Chuck Hagenbuch)
New features should go into a new package. Net_Socket is purely in maintenance mode.
 [2008-12-01 17:37 UTC] chagenbu (Chuck Hagenbuch)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. I was closing other bugs so I changed my mind, cleaned up the patch, and committed it. Please look at coding standards next time, and use the upload feature for patches so the lines don't get butchered.