Contents of /mcore-src/trunk/mcore-tools/socket_send.php
Parent Directory
|
Revision Log
Revision 2048 -
(show annotations)
(download)
Wed May 8 11:07:56 2013 UTC (11 years ago) by niro
File size: 931 byte(s)
Wed May 8 11:07:56 2013 UTC (11 years ago) by niro
File size: 931 byte(s)
-added socket_send.php helper script
1 | <? |
2 | // $address = "192.168.0.6"; |
3 | // $port = "6666"; |
4 | // |
5 | // // create and connect socket |
6 | // $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); |
7 | // socket_connect($sock, $address, $port); |
8 | // |
9 | // // send the message to the daemon |
10 | // //$mesg = "resolution=800x600\nquit"; |
11 | // $mesg = "resolution\nquit"; |
12 | // //$mesg = "printer\ngfxcard\nnetcard\nkeyboard\nmouse\nsound\nquit"; |
13 | // socket_write($sock, $mesg, strlen($mesg)); |
14 | // |
15 | // // close socket |
16 | // socket_close($sock); |
17 | |
18 | |
19 | /* fgets needs 'auto-detect-line-endings = On' in php.ini to detect unix CRLFs! |
20 | * see: http://www.php.net/manual/de/filesystem.configuration.php#ini.auto-detect-line-endings |
21 | */ |
22 | |
23 | |
24 | // ssl |
25 | $fp = fsockopen("ssl://192.168.0.6", 6666, $errno, $errstr, 30); |
26 | if (!$fp) { |
27 | echo "$errstr ($errno)<br />\n"; |
28 | } else { |
29 | $out = "resolution\n"; |
30 | $out .= "quit\n"; |
31 | fwrite($fp, $out); |
32 | while (!feof($fp)) { |
33 | echo fgets($fp, 128); |
34 | } |
35 | fclose($fp); |
36 | } |
37 | ?> |