Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

socket io across two different ports

global.appRoot = require('app-root-path');

var express = require('express');
var session = require('express-session');
var app = express();

var server1 = app.listen(7788, "0.0.0.0", function() {
    console.log('Server listening on port ' + server1.address().port);
});

var server2 = app.listen(5566, "0.0.0.0", function() {
    console.log('Server listening on port ' + server2.address().port);
});

var socket = require('socket.io').listen(server1);
var socket2 = require('socket.io').listen(server2);

socket.on('connect', function (socket) {
    console.log("hi socket 1");
});

socket2.on('connect', function (socket) {
    console.log("hi socket 2");
});
Comment

socket io across two different ports

<!doctype html>
<html>
    <head>
        <script src='https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.1/socket.io.js'></script>
        <script>
            var socketClient1 = io('ws://localhost:5566');
            var socketClient2 = io('ws://localhost:7788');
        </script>
    </head>
    <body>
        <ul id='messages'></ul>
    </body>
</html>
Comment

PREVIOUS NEXT
Code Example
Javascript :: discord js mention author 
Javascript :: switch case in jsx 
Javascript :: Merge Arrarys of Object of Any size 
Javascript :: arrow function no argument object 
Javascript :: reduce example 
Javascript :: Jboss heap dump 
Javascript :: set-date-picker-range-with-in-a-financial-year-based-on-the-document 
Javascript :: vscode decrease window tab 
Javascript :: for range a, z javascript 
Javascript :: initializing a property asynchronously 
Javascript :: Copy an Array with the Spread Operator 
Javascript :: float vape pen instructions 
Javascript :: vscode nestjs ignore node_modules 
Javascript :: hello worled anglular script 
Javascript :: How to create a debounce higher order function 
Javascript :: jquery meta characters escape 
Javascript :: Use ChainLink Feed Registry 
Javascript :: Use Set to ensure the uniqueness of a list of values javascript 
Javascript :: uplaod file in s3 from heroku for node js 
Javascript :: what is the opposite of lazy initialization 
Javascript :: bootstrap dropdown with state 
Javascript :: a method that will do something to each of the values in the array 
Javascript :: delete nth node from end 
Javascript :: Check if something is a function 
Javascript :: Remove the minimum 
Javascript :: aboutreact axios 
Javascript :: Will Yield A "Function" 
Javascript :: json to css converter 
Javascript :: how to cut and paste an element in vanilla javascript 
Javascript :: Listen to custom event in Vue.js 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =