UNPKG

enip-ts

Version:

Typescript implementation of the Ethernet/IP™ protocol.

36 lines 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ENIPServer = void 0; const net_1 = require("net"); const stream_1 = require("stream"); const client_1 = require("./client"); const EIP_PORT = 44818; /** Server Socket controller */ class ENIPServer { server; clients = []; events; constructor(vector) { this.server = (0, net_1.createServer)((client) => { this.clients.push(new client_1.Client(client, vector)); }); this.events = new stream_1.EventEmitter(); } /** * Make Enip Server listening * @param port Port used by this server * @returns true if listening successfully, false if not. */ async listen(port = EIP_PORT) { return new Promise(resolve => { try { this.server.listen(port, () => resolve(true)); } catch (ex) { resolve(false); } }); } } exports.ENIPServer = ENIPServer; //# sourceMappingURL=index.js.map