jSocket 介绍
jSocket 是 JavaScript 实现 Socket 通讯的解决方案。
示例代码:
<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>
jSocket 官网
http://code.google.com/p/jsocket/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。