Last active
September 6, 2018 12:13
-
-
Save kevinSuttle/85b3b6c6d480c3842242 to your computer and use it in GitHub Desktop.
Socket.io, Express-generator troubleshooting
This file contains hidden or 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 express = require('express'), | |
https = require('https'); | |
//... | |
var app = express(); | |
// ... | |
module.exports = app; |
This file contains hidden or 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
window.onload = function() { | |
socket = io.connect('http://127.0.0.1:3333'); | |
socket.on('connect', function () { | |
socket.send('hi'); | |
}); | |
} |
This file contains hidden or 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
#!/usr/bin/env node | |
var debug = require('debug')('app:www'); | |
var app = require('../app'); | |
var server = require('http').createServer(app); | |
var io = require('../io'); | |
var localHost = 'http://127.0.0.1' | |
var localPort = '3333'; | |
app.host = app.set('host', process.env.HOST || localHost); | |
app.port = app.set('port', process.env.PORT || localPort); | |
var server = app.listen(app.get('port'), function() { | |
app.address = app.get('host') + ':' + server.address().port; | |
console.log('Express server listening at ' + app.address); | |
}); | |
io.attach(server); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment