-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_exploration.php
57 lines (39 loc) · 1.23 KB
/
start_exploration.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
<?php
$proxy_port = $_POST['proxyport'];
$server_port = $_POST['serverport'];
//start the JAVA proxy program
//exec("java -classpath ./java_file/ Proxy {$server_port} {$proxy_port} >>/dev/null 2>>/dev/null &");
//sleep for 2 seconds
//sleep(10);
/* Get the IP address for the target host. */
//$address = gethostbyname('www.google.com');
$address = "localhost";
/* Create a TCP/IP socket. */
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or die('Could not create socket.');
$result = socket_connect($socket, $address, $proxy_port) or die('Socket connection is failed.');
/*
$data = array();
$samples = array();
$points = array();
//$data[] = array("rowc" => 23.45, "colc" => 0.234);
//$data[] = array("rowc" => 14.78, "colc" => 1.32);
$samples[] = array(23.45, 0.234);
$samples[] = array(14.78, 1.32);
$data["samples"] = $samples;
$points[] = array(50.4, 4.32);
$points[] = array(30.6, 3.21);
$data["points"] = $points;
echo json_encode($data);
*/
//$in = json_encode($data);
//$in .= "\n";
$out = '';
//socket_write($socket, $in, strlen($in));
//$out = socket_read($socket, 20480);
while($resp = socket_read($socket, 1000)) {
$out .= $resp;
if (strpos($resp, "\n") !== false) break;
}
echo $out;
socket_close($socket);
?>