"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.endConnection = void 0;
const constants_1 = require("./constants");
function endConnection({ socket, response, args }) {
    // either use the raw buffer (if available) or create a new one
    const responseBuffer = args.requestBuffer || Buffer.allocUnsafe(2);
    if (!args.requestBuffer) {
        responseBuffer[0] = constants_1.RFC_1928_VERSION;
    }
    responseBuffer[1] = response;
    // respond then end the connection
    try {
        socket.end(responseBuffer);
    }
    catch (ex) {
        socket.destroy();
    }
}
exports.endConnection = endConnection;
//# sourceMappingURL=end-socket-connection.js.map