Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/socket_send.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2622 - (hide annotations) (download)
Fri Sep 25 12:40:08 2015 UTC (8 years, 8 months ago) by niro
File size: 933 byte(s)
-use sslv3 in socket send example
1 niro 2048 <?
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 niro 2622 $fp = fsockopen("sslv3://192.168.0.6", 6666, $errno, $errstr, 30);
26 niro 2048 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     ?>