# New Ticket Created by  Aleks-Daniel Jakimenko-Aleksejev 
# Please include the string:  [perl #131766]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=131766 >


It should be possible to specify the source address of outgoing (client) 
connections. This is especially useful if the machine has more than one IP 
address.

Examples in other software:
* wget supports --bind-address parameter: 
https://www.gnu.org/software/wget/manual/wget.html#Download-Options
* Python accepts optional “source_address” parameter: 
https://docs.python.org/2/library/socket.html#socket.create_connection
* “bind before connect”, a blog post that seems to be relevant: 
https://idea.popcount.org/2014-04-03-bind-before-connect/
* curl seems to allow it too, but surprisingly it can also accept the interface 
name: https://curl.haxx.se/docs/manpage.html#--interface

It is possible to find more examples of languages that support it, but I'm sold 
already.


My best guess is that it is doable by simply calling uv_tcp_bind for outgoing 
connections.

Relevant links:
* 
https://github.com/MoarVM/MoarVM/blob/2a79727deb78105c8c9f660a1136a3db1179b09b/src/io/asyncsocket.c#L532-L533
* 
https://github.com/MoarVM/MoarVM/blob/2a79727deb78105c8c9f660a1136a3db1179b09b/src/io/asyncsocket.c#L681-L683

Reply via email to