首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

JavaScript的Socket通信包 jSocket

2013-11-02 
JavaScript的Socket通讯包 jSocketscript typetext/javascript// Host we are connecting tovar host

JavaScript的Socket通讯包 jSocket
<script type='text/javascript'> // Host we are connecting to var host = 'localhost'; // Port we are connecting on var port = 3000; var socket = new jSocket(); // When the socket is added the to document socket.onReady = function(){ socket.connect(host,port); } // Connection attempt finished socket.onConnect = function(success){ if(success){ // Send something to the socket socket.send('Hello world'); }else{ alert('Connection to the server could not be estabilished'); } } socket.onData = function(data){ alert('Received from socket: '+data); } // Setup our socket in the div with the id="socket" socket.setup('#socket'); </script>

?下载地址:http://code.google.com/p/jsocket/

热点排行