各位, 用Node.js的Net模块,如何指定Socket 客户端的本地端口,不是Socket服务端的监听端口
How can I know, what local port is used by Stream?
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:
Local port specified explicitly is required by Scala Remote Actors communication protocol - that's what I need it for.
I want to open a client socket (not a server socket, which reacts to outgoing connections). Every client socket is bound to a local port, which is used to receive response from the server socket. I'm trying to figure out in runtime, which port is used. With netstat -tlnp it's possible to figure out, which port is used by the client socket (by process ID), but I want to have something less cumbersome
According to the node.js documentation (http://nodejs.org/api.html) there is no method or variable exposed that provides the information you are looking for. I would suggest either submitting a patch (http://nodejs.org/#contributing) or making a request through a mailing list (http://groups.google.com/group/nodejs).