-
Notifications
You must be signed in to change notification settings - Fork 3
/
test2.php
42 lines (32 loc) · 1.03 KB
/
test2.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
<?php
//Server
set_time_limit(0);
$host = '192.168.1.185';
$port = 5010;
$socket = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($socket, $host, $port);
socket_listen($socket);
$client = array($socket);
$realclient = array($socket);
while (true) {
//$read=$client;
$cliid = 0;
socket_select($client, $write = NULL, $except = NULL, $tv_sec = NULL);
if (in_array($socket, $client)) {
for ($i = 1; $i < 5; $i++) {
if (!isset($client[$i])) {
$tmp = socket_accept($socket);
socket_write($tmp, hex2bin('A50000000038000093D6'));
$request = bin2hex(socket_read($tmp, 2024));
$realclient[$request[9]]['socket'] = $tmp;
if(count($realclient) == 3){
break;
}
} //inside if
} //for
break;
}
} //while
print_r($realclient);
socket_close($socket); //for accepting
?>