public function ForFsockopen () {
$host = '127.0.0.1:8000';
$port = 80;
$errno = '';
$errstr = '';
$timeout = 30;
$url = '/testfsock';
$param = array(
'name' => 'fdipzone',
'gender' => 'man'
);
$data = http_build_query($param);
// create connect
$fp = fsockopen($host, $port, $errno, $errstr, $timeout);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
// $out = "GET $url HTTP/1.1\r\n";
// $out .= "Host: $host\r\n";
// $out .= "Connection:close\r\n\r\n";
$out = "POST $url HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
$out .= "Content-Length: ".strlen($data)."\r\n";
$out .= "Referer: http://".$host.$url."\r\n";
$out .= "X-CSRF-TOKEN:csrf_token()\r\n";
$out .= "Cookie: username=admin;uid=200\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
fclose($fp);
}
}
public function TestFsock () {
$fp = fopen('file/test.txt', 'a');
for ($i = 0; $i < 1000; $i ++ ) {
fwrite($fp, '888888');
}
fclose($fp);
}
Route::get('/forsockopen', "TestController@ForFsockopen");
Route::post('/testfsock', "TestController@TestFsock");
// Route::get('/testfsock', "TestController@TestFsock");