"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const net_1 = __importDefault(require("net"));
/**
 * Socket工具类
 */
class SocketUtil {
    static send(options, data) {
        return new Promise((resolve, reject) => {
            try {
                let socket = net_1.default.connect(options);
                socket.on('connect', () => {
                    socket.write(data);
                    socket.destroy();
                    resolve();
                });
                socket.on('error', (error) => {
                    socket.destroy();
                    reject(error);
                });
            }
            catch (error) {
                reject(error);
            }
        });
    }
}
exports.default = SocketUtil;
