Roman Neuhauser wrote: > # jochem@xxxxxxxxxxxxx / 2007-01-20 01:30:55 +0100: >>> I definitely give a hoot about the content returned ... all I want >>> is for the request to go out on the wire and then have my script >>> immediately continue with what it should be doing. >>> >>> I believe this would require creating a non-blocking connection in >>> some way, but I'm stuck as to the correct way to tackle this. I've >>> been reading about non-blocking sockets/streams etc but I'm just >>> becoming more and more confused really, anyone care to put me out of >>> my misery? >> did more reading, still unsure of the whole thing, this is what I have >> right now: >> >> $url = array('', 'tbs.tradedoubler.com', '/report?blablablabla'); >> $isSSL = true; >> $proto = $isSSL ? 'ssl://' : 'http://'; >> $port = $isSSL ? 443 : 80; >> $errno = $errstr = null; >> if ($sock = fsockopen($proto.$url[1], $port, $errno, $errstr, 10)) { >> stream_set_blocking($sock, 0); >> fwrite($sock, "GET {$url[2]} HTTP/1.0\r\n"); >> fwrite($sock, "Host: {$url[1]}\r\n"); >> //fwrite($sock, "Content-length: 0\r\n"); >> //fwrite($sock, "Accept: */*\r\n"); >> fwrite($sock, "\r\n"); >> fclose($sock); >> } >> >> does this make any sense, will this work at all? >> would the 10 second timeout [potentially] negate all the hard work? > > Yes, you need to wait for the socket to connect, and that's synchronous > in all cases. I don't know enough about sockets in PHP to help further > here, but if the semantics follows write(2) behavior in C, then what you > have is broken. Non-blocking IO means the fwrite() could return before > it could write all you gave it (it returns how many bytes it's written). ah yes, I did read that, you pointing it out has made it become clearer. that would mean the 'fastest' I could push out the http request is probably by doing: if ($sock = fsockopen($proto.$url[1], $port, $errno, $errstr, 4)) { fwrite($sock, "GET {$url[2]} HTTP/1.0\r\n"); fwrite($sock, "Host: {$url[1]}\r\n"); fwrite($sock, "\r\n"); fclose($sock); } but I'd have to check with tradedoubler if they could indicate what their 'report' server's maximum response time could be (hopefully very low) for the timeout AND find out whether their 'report' server does something similar to ignore_user_abort(). anyway thanks for your input! > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php