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!!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With