You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
372 B
15 lines
372 B
'use strict';
|
|
|
|
const connectSocket = (conn, port, host) => {
|
|
return new Promise((resolve) => {
|
|
const errorHandler = (e) => resolve({ error: true, data: e })
|
|
conn.connect(port, host, () => {
|
|
conn.removeListener('error', errorHandler);
|
|
resolve({ error: false, data: { port, host } })
|
|
});
|
|
conn.on('error', errorHandler)
|
|
})
|
|
};
|
|
|
|
|
|
module.exports = connectSocket
|
|
|