Using netstat i found this in my list
TCP 127.0.0.1:9832 My-PC:9832 ESTABLISHED
My question is how is my local port outgoing AND CONNECTED to the same TCP port?
This is breaking my code because i am listening to port 9832. I am getting a permission error. I need to lose firefox and reopen all my tabs before this code will work. Another question i 开发者_StackOverflowguess would be is there a range that should be used for listening and will not be use as an outgoing connection?
I am confused.
It is perfectly valid to use the same port number for both outgoing connections and listening. If you are connecting to your own computer, then you'll get netstat output like you showed.
A TCP connection is identified by the 4-tuple (source-ip, source-port, dest-ip, dest-port), so there's nothing that says source-port cannot be the same as dest-port.
Perhaps you are binding to a particular port in your client code? Normally you only need to bind to a specific port for the server code.
Your issue about having to close Firefox is undoubtedly unrelated to this.
精彩评论