相關關鍵詞
關于我們
最新文章
php實現(xiàn)與python進行socket通信的方法示例
本文實例講述了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>