Idea for Net_Socket
| From: | Matthew Fonda | Date: | Sun, 30 Jan 2005 00:02:54 +0000 |
| Subject: | Idea for Net_Socket | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-35797@lists.php.net to get a copy of this message | ||
Hello,
I have been using Net_Socket, and I noticed that if the it fails to
connect in the Net_Socket::connect method for whatever reason, it
creates a fatal php error as opposed to raising a pear error like it
looks like its supposed to.
This could be fixed easily by just adding @ before it to suppress
errors.
So change line 106/108 to
$fp = @$openfunc($this->addr, $this->port, $errno, $errstr,
$this->timeout);
$fp = @$openfunc($this->addr, $this->port, $errno, $errstr);
The code right after the connection is:
if (!$fp) {
return $this->raiseError($errstr, $errno);
}
but that will never be true, because it will die if the connection
failed, so it wouldnt make it to that line.
Maybe it was meant to be that way, but I think it would be a lot nicer
to have a PEAR error and handle if it didnt connect on my own, than have
a fatal PHP error.
Thanks
--
Regards,
Matthew Fonda