Using socket.io standalone without node.js

后端 未结 3 873
旧巷少年郎
旧巷少年郎 2020-12-03 10:39

(JavaScript newbie)

I am trying to build a JavaScript based client app that communicates with a server app over socket. I came across socket.io. Is it possible to us

3条回答
  •  失恋的感觉
    2020-12-03 10:51

    As I understand, you need a socket.io server without node.js, right? If to use socket.io just as cross-browser WebSockets would be sufficient, and what i mean by that is nicely illustrated in the following example from socket.io web site:

    var socket = io.connect('http://localhost/');
    socket.on('connect', function () {
      socket.send('hi');
    
      socket.on('message', function (msg) {
        // my msg
      });
    });
    

    It would make your server code very simple. Surely, you can find some WebSockets library for your language or even write your own. Look at this SO question for examples.

    Or if you want to use socket.io protocol there is list of socket.io libraries for different languages, like python and java.

提交回复
热议问题