enip-ts
Version:
Typescript implementation of the Ethernet/IP™ protocol.
49 lines (48 loc) • 1.59 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
import { Socket } from "net";
import type { ENIPEventEmitter } from "./events";
import type { ENIPState } from "./states";
/**
* Low Level Ethernet/IP
*/
export declare class SocketController {
state: ENIPState;
socket: Socket;
events: ENIPEventEmitter;
port: number;
constructor(timeout?: number, port?: number);
/**
* Initializes Session with Desired IP Address or FQDN
* and Returns a Promise with the Established Session ID
* @param IpAddress IP Address or FQDN of the Controller
* @param timeout Timeout in Milliseconds for Session Registration
*/
connect(IpAddress: string, timeout?: number): Promise<number | undefined>;
/**
* Writes Ethernet/IP Data to Socket as an Unconnected Message or a Transport Class 1 Datagram
* @param data Data to be sent
* @param connected If the message should be sent as a connected message
* @param timeout Timeout in Milliseconds for the response
*/
write(data: Buffer, connected?: boolean, timeout?: number): Promise<boolean>;
/**
* Sends Unregister Session Command and Destroys Underlying TCP Socket
* @deprecated
*/
destroy(_error?: Error): void;
/**
* Sends an UnregisterSession command
*/
close(): void;
/**
* Socket data event handler
* @param data Data received from the socket
*/
private handleData;
/**
* Handle socket close
* @param _hadError If the socket closed due to an error
*/
private handleClose;
}