Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In either http.request or net.connect, is there an option that I can specify a network interface to initiate a connection?

EDIT: AFAIK in OS level I can specify address level, or load balancing into routing tables. But the way of interface choosing in my software is more than that, I wanna know if I can do that in codes.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
999 views
Welcome To Ask or Share your Answers For Others

1 Answer

Node has this built in:

http://nodejs.org/api/net.html#net_net_connect_options_connectionlistener

http://nodejs.org/api/http.html#http_http_request_options_callback

See localAddress, just set that to the IP of the interface you'd like to use.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...