| 1234567891011121314151617181920212223242526272829303132333435 | 
							- <?php
 
- namespace app\index\controller;
 
- use think\Controller;
 
- class Index extends Controller
 
- {
 
-     public function index(){
 
-         return $this->view->fetch();
 
-     }
 
-     public function test()
 
-     {
 
-         $st="test/test";
 
-         $length = strlen($st);
 
- //创建tcp套接字
 
-         $socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
 
- //连接tcp
 
-         socket_connect($socket, '121.5.123.166',2347);
 
- //向打开的套集字写入数据(发送数据)
 
-         $s = socket_write($socket, $st, $length);
 
- //从套接字中获取服务器发送来的数据
 
-         /*while(true){*/
 
-             $msg = socket_read($socket,2347);
 
-             echo $msg;
 
-             /*sleep(1);
 
-         }*/
 
- //关闭连接
 
-         socket_close($socket);
 
-     }
 
- }
 
 
  |