How can I find out which local port is used by Stream?

Is it possible to indicate explicitly the local port that net.Stream should use, or to find out which local port is used to connect?

According to the documentation, the local port cannot be specified:

 stream.connect(port, host='127.0.0.1') 
+4
source share
3 answers
 stream.connect(port, host='127.0.0.1') 

The specified address with the specified port is specified.

If you want to open a socket, you must use net.createConnection(port, host='127.0.0.1') , http.createServer or smth, like this ... On Linux, to show all sockets listened, enter netstat -an

+1
source

According to node.js documentation ( http://nodejs.org/api.html ) there is no way or variable that provides the information you are looking for. I suggest either sending the patch ( http://nodejs.org/#contributing ) or making a request through the mailing list ( <a2> ).

0
source

If you are managing a server, you can ask him to tell you. Not really, but not like the hoops you have to jump with when trying to negotiate peer-to-peer connections due to NAT.

0
source

All Articles