nospaceships / node-raw-socket

Raw sockets for Node.js.
207 stars 69 forks source link

Added bindToAddress and bindToDevice #43

Closed somec closed 5 years ago

somec commented 6 years ago

On a multihomed node it might be wanted to bind the socket to a specific address or interface.

Added two functions:

stephenwvickers commented 5 years ago

Hi @somec

While I appreciate this patch request I will not be merging it.

For the bind to device functionality you can already do this using a socket option, so this really should be done in JavaScript (i.e. index.js) and not in C++.

Additionally, I am not sure I see the benefit of binding to a specific IP address, specifically for a raw socket socket. If you really do need to control the source IP address then you should consider using IP_HDRINCL socket option and control that yourself.

Steve