国产精品成人VA在线观看,亚洲日韩在线中文字幕综合,亚洲AV电影天堂男人的天堂,久久人人爽人人爽人人av东京热

News新聞

業(yè)界新聞動態(tài)、技術前沿
Who are we?

您的位置:首頁      樂道系統(tǒng)FAQ      php實現(xiàn)與python進行socket通信的方法示例

php實現(xiàn)與python進行socket通信的方法示例

標簽: 發(fā)布日期:2017-08-30 00:00:00 243

本文實例講述了php實現(xiàn)與python進行socket通信的方法。分享給大家供大家參考,具體如下:

設計目的

通過前端頁面發(fā)起請求交給php,php創(chuàng)建socket請求交給Python腳本,然后執(zhí)行完畢之后,返回給前端。

index.html

<html>
<head>
  <title>test</title>
  <script>
  g_xmlHttpReq = new XMLHttpRequest();
  function onReplyCallback()
  {
    if(g_xmlHttpReq.readyState==4 && g_xmlHttpReq.status==200)
    {
      alert(g_xmlHttpReq.responseText);
    }
  }
  function on_stop_service()
  {
    g_xmlHttpReq.open("GET","./service/main.php?cmd=1",true);
    g_xmlHttpReq.onreadystatechange=onReplyCallback;
    g_xmlHttpReq.send(null);
  }
  </script>
</head>
<body>
<button onclick="on_stop_service()">關閉服務</button>
</body>
</html>