forked from AbhishekGhosh/invalid-pointer-0x00007f75ec3ff0e0
/
test.php
57 lines (44 loc) · 1.2 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
class Server {
private $socket;
public function __construct() {
$this->socket = stream_socket_server("tcp://127.0.0.1:9000", $errNo, $errMessage, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN);
if($this->socket === false) throw new Exception("Server Error: $errMessage");
$this->loop();
}
public function loop() {
while(true) {
$client = stream_socket_accept($this->socket, -1, $peername);
if($client) {
echo "New($peername)\n";
$clients[] = new Client($client);
} else {
echo "Fail.\n";
}
}
}
}
class Client extends Thread {
private $socket;
public function __construct($socket) {
$this->socket = $socket;
$this->start();
}
public function run() {
$client = $this->socket;
fwrite($client, "Hello.Bye.\n");
stream_socket_shutdown($client, STREAM_SHUT_RDWR);
fclose($client);
}
}
new Server();
?>
<?php
function is_file_cached($file) {
$info = apc_cache_info();
foreach ($info['cache_list'] as $cache) {
if ($cache['filename'] == $file) return true;
}
return false;
}
?>