hello,
thank you for the help, but I've tried your code, and it returns the
exact same thing :( the error #11 temporarily unavailable. If I remove
non-blocking, or change the error to ignore to 11 (10035 in your code
example) it simply "hangs" doing nothing *at all*...
I'm stumped; really.. thank you for trying though :)
- tul
Tom Rogers wrote:
Hi,
Saturday, September 3, 2005, 9:19:11 AM, you wrote:
MS> hello,
MS> I'm writing a socket approach to send email directly via an SMTP server
MS> (since some hosts block sendmail trough php due to abuse). Now, I have
MS> the code, attached below:
MS> I have cut it down slightly so it would still be readable though. I'm
MS> very sure that none of the stuff I removed actually matters in the
MS> problem though (mostly error chechking, logging, debug stuff, etc).
MS> Ok, back to the problem. If I reread my log, I see the following "output":
MS> S: 220 server -- Server ESMTP (iPlanet Messaging Server 5.2)
MS> C: HELO ip
MS> S:
MS> C: MAIL FROM: <me@xxxxxxxxxxx>
MS> S: 250 server OK, server2 [ip].
MS> C: RCPT TO: <you@xxxxxxxxxxx>
MS> S:
MS> C: RSET
MS> Now, obviously, the server sends something back (I checked, manually,
MS> using telnet). So, I figured that the socket_read(socket, size,
MS> PHP_NORMAL_READ) was causing the problem. So I switched over to
MS> PHP_BINARY_READ to make sure I didn't miss anything (because it broke
MS> off eg. midways). So... after I changed that, I suddenly started getting
MS> these errors:
MS> Warning: socket_read() unable to read from socket [11]: Resource
MS> temporarily unavailable in /home/me/scripts/mail.php on line 27
MS> This goes for each attempt to read (even the first). I'm stumped... and
MS> really don't know how to proceed now...
MS> Does anyone have any clues?
MS> very appreciated,
Because of this line the function returns straight away.
MS> socket_set_nonblock($this->socket);
You have to catch the 'not ready' error something like this:
(The error code was under windows)
function get(){
$ret = '';
while(1){
$sbuf = @socket_read($this->connection, 1024, PHP_BINARY_READ);
if(false === $sbuf){
$error = socket_last_error($this->connection);
if($error != 10035){
echo "msgsock read() failed: reason: " .$error.' '. socket_strerror (socket_last_error($this->connection)) . "\n";
return;//socket not happy
}
}else{
$buf_read = strlen($sbuf);
if($buf_read === 0) break; // end of text
$ret .= $sbuf;
}
}
return $ret;
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php