For what it's worth, this simple example below works in my Android browser. Let us know if you need something specific that is not discussed below - it is important: Change the IP number and port to whatever suits your environment:
var express = require('express'), socketio = require('socket.io'), app = express.createServer(), io = socketio.listen(app); var index = "<!doctype html>\ <html>\ <head>\ <script src=/socket.io/socket.io.js></script>\ <script>\ var socket = io.connect('http://10.0.1.29:3000');\ function send() {\ socket.emit('foo', 'Ben', function(data) {\ alert(data);\ });\ }\ </script>\ </head>\ <body>\ <button onclick='send();'>Send</button>\ </html>"; app.get('/', function(req, res) { res.send(index); }); io.sockets.on('connection', function(socket) { socket.on('foo', function(name, f) { f('Hello ' + name); }); }); app.listen(3000);
Linus Gustav Larsson Thiel
source share