views:

169

answers:

3

Is it possible to specify explicitly local port that should be used by net.Stream, or to find out what local port is used for connection?

According to the documentation, local port cannot be specified:

stream.connect(port, host='127.0.0.1')
+2  A: 
stream.connect(port, host='127.0.0.1')

listed the specified address with specified port.

If you want to open socket, you have to use net.createConnection(port, host='127.0.0.1'), http.createServer or smth like that... In Linux to show all listened sockets, type netstat -an

Alex Ivasyuv