Closed davehorton closed 5 years ago
This covers your use case, but there are other options in the net.createConnection()
method and I don't want to add a param everytime there is one someone needs.
What if instead of changing the constructor to add the param we just supported passing in a socket directly as the first param? That way you can configure it however you want and just pass it in.
Something that would be used like:
var net = require('net');
var esl = require('modesl');
var socket = net.connect(/* your options */);
var conn = new esl.Connection(socket, function () { /* connect listener */ });
That ensures that you can configure the socket however you want. Problem then becomes how to distinguish between an Inbound and Outbound socket. Because (socket, listener)
is assumed to be an Outbound connection right now!
Maybe a static method like .createInboundFromSocket(socket)
or something? Not sure...
Closing this as v2 will support this use case in a couple different ways.
On a server with multiple IP addresses it can be necessary to be able to specify which interface/address to bind the client socket to.