|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-03-16 15:16 UTC] manu at chasqui dot uclv dot edu dot cu
A few months ago, I was doing transfers using socket functions, it all worked fine(php 4.0.4 or php 4.0.5).
I code something like this:
$p = fsockopen( $url, $port );
if (!$p) die('Cannot connect');
$l = fputs( $p, $data );
fclose( $p );
With this I sent up to 5MBs to a server. Now, the web server's administrator has upgrade to 4.1.1. The php.ini file has:
post_max_size=10M
upload_max_filesize=5M
The fact is that it works but doesn't sending large streams. I make a test with a string of 100Kb of text, and the server received only 8Kb(and sometimes less).
I inserted a dead loop before fclose and still the server got the client disconnection before de php_max_execution_time elapsed.
The same thing happens in php 4.0.6.
Manu.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 03:00:02 2025 UTC |
I did something like this. Didn't work. $socket = fsockopen( $host, $port, $err1, $err2, 30 ); if (!$socket) die ('conn'); $start = 0; $len = 4*1024; $result = 0; while ($result < strlen($request)) { $chunk = substr( $request, $start, $start+$len ); $result = $result + fputs( $socket, $chunk ); fflush( $socket ); $start = $start+$len; } fclose( $socket ); Hope you find the answer. :-> Manu.The lastest snapshot(Oct 13, 2002; php4-win32-latest.zip) works almost fine. This code: $socket = @fsockopen( 'localhost', 80, $err1, $err2 ); if (!$socket) die('socket not open'); $result = fputs( $socket, $request ); #$request holds a well formed MIME request for posting a file. fflush( $socket ); //echo "<pre>>>\r\n".str_replace('</pre>', '</pre>', $request)."<<\r\n</pre>"; fclose( $socket ); This works if the file being posted is small(can't say how much). The point is that if I uncomment the echo line before fclose(), it sends all the data(up to 10.5M=11,076,608 bytes I sent), but without the echo line, it seems that fclose() executes in such a way that chops the socket's output stream and the Web Server does not executes the receive.php script. The echo line may be replace by sleep(8) and still working. Summary: Give it time before fclose() a works; otherwise, unstable. Manu.