index.js
function listen(port, cb) {
    return new Promise((resolve, reject) => {
        let completed = ssocket_helpers.createSimplePromiseCompletedAction(resolve, reject);
        try {
            let serverToClient;
            let server = Net.createServer((connectionWithClient) => {
                try {
                    if (cb) {
                        cb(null, createServer(connectionWithClient));
                    }
                }
                catch (e) {
                    if (cb) {
                        cb(e);
                    }
                }
            });
            let isListening = false;
            server.once('error', (err) => {
                if (!isListening && err) {
                    completed(err);
                }
            });
            server.on('listening', () => {
                isListening = true;
                completed(null, server);
            });
            server.listen(port);
        }
        catch (e) {
            completed(e);
        }
    });
}
function listen(port, cb) {
    return new Promise((resolve, reject) => {
        let completed = ssocket_helpers.createSimplePromiseCompletedAction(resolve, reject);
        try {
            let serverToClient;
            let server = Net.createServer((connectionWithClient) => {
                try {
                    if (cb) {
                        cb(null, createServer(connectionWithClient));
                    }
                }
                catch (e) {
                    if (cb) {
                        cb(e);
                    }
                }
            });
            let isListening = false;
            server.once('error', (err) => {
                if (!isListening && err) {
                    completed(err);
                }
            });
            server.on('listening', () => {
                isListening = true;
                completed(null, server);
            });
            server.listen(port);
        }
        catch (e) {
            completed(e);
        }
    });
}
function listen ( port , cb ) { return new Promise ( ( resolve , reject ) => { let completed = ssocket_helpers . createSimplePromiseCompletedAction ( resolve , reject ) ; try { let serverToClient ; let server = Net . createServer ( ( connectionWithClient ) => { try { if ( cb ) { cb ( null , createServer ( connectionWithClient ) ) ; } } catch ( e ) { if ( cb ) { cb ( e ) ; } } } ) ; let isListening = false ; server . once ( 'error' , ( err ) => { if ( ! isListening && err ) { completed ( err ) ; } } ) ; server . on ( 'listening' , ( ) => { isListening = true ; completed ( null , server ) ; } ) ; server . listen ( port ) ; } catch ( e ) { completed ( e ) ; } } ) ; }
Starts listening on a port.

@param {number} port The TCP port to listen on.
@param {ListenCallback} cb The listener callback.

@return {Promise<Net.Server>} The promise.
Starts listening on a port .