Created
July 7, 2017 20:29
-
-
Save stephanbogner/ce298b85bdab2b11e08fcc55f10fe884 to your computer and use it in GitHub Desktop.
Simplest example of sending data from client to server in localhost network
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="socket.io.min.js"></script> | |
<script> | |
var ipOfLaptop = '192.168.2.107'; | |
var definedPort = 8123; | |
var host = 'http://' + ipOfLaptop + ':' + definedPort; | |
var socket = io(host); | |
socket.emit('msg', 'test'); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var definedPort = 8123; | |
var ioIn = require('socket.io').listen(definedPort); | |
ioIn.on('connection', function(socketIn) { | |
socketIn.on('msg', function(msg) { | |
console.log('msg', msg); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment