Reputation: 533
Sending a request from NodeJs, I want to specify the starting port, for example:
request to google.com port 80
from port 52000.
So the connection will be from from port 52000 to 80.
My goal is to bootstrap a web server under a NAT, but I'm not allowed to set the forwarding port on the NAT itself.
How can I perform it?
Thank you!!
Upvotes: 3
Views: 1068
Reputation: 11805
In the official node documentation (which I advise you to check), you have a localAddress
and localPort
properties, which you can use to bind to them before connecting to a remote socket.
That's the lowest level. Node HTTP requests expose the socket, so you can use it to access those properties, or you can write your own HTTP requester with basic nodejs sockets.
Upvotes: 2