端口混淆(破坏了我的 .NET 代码)
使用 netstat 我在我的列表中找到了这个
TCP 127.0.0.1:9832 My-PC:9832 ESTABLISHED
我的问题是我的本地端口如何传出并连接到同一 TCP 端口?
这破坏了我的代码,因为我正在侦听端口 9832。我收到权限错误。我需要丢失 Firefox 并重新打开所有选项卡,此代码才能工作。我猜的另一个问题是是否有一个范围应该用于监听并且不会用作传出连接?
我很困惑。
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 guess would be is there a range that should be used for listening and will not be use as an outgoing connection?
I am confused.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于传出连接和侦听使用相同的端口号是完全有效的。如果您连接到自己的计算机,那么您将获得像您所示的 netstat 输出。
TCP 连接由 4 元组(源 IP、源端口、目标 IP、目标端口)标识,因此没有任何内容表明源端口不能与目标端口相同。
也许您正在客户端代码中绑定到特定端口?通常,您只需为服务器代码绑定到特定端口。
您关于必须关闭 Firefox 的问题无疑与此无关。
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.