Socket.bind() 返回“请求的地址在其上下文中无效。”在Win7上
我尝试以这种方式使用 Socket.bind() 函数:
Bind(new IPEndPoint(myInternalAddress, myPort));
我收到的错误是“请求的地址在其上下文中无效。”,但这仅发生在 Windows 7 上(我使用的是 64 位)。
几天前升级之前,一切正常,我检查了 IP 是否正确。
任何关于这里到底出了什么问题的帮助将不胜感激。
I am trying to use the Socket.bind() function this way:
Bind(new IPEndPoint(myInternalAddress, myPort));
The error I am getting is "The requested address is not valid in its context.", but this only happens on Windows 7 (I am using 64 bit).
Befor my upgrade a few days ago this was working fine, and I checked the IPs to be the correct ones.
Any help would be appreciated on what exactly goes wrong here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
bind()
...将套接字绑定到本地IP地址和端口。这就是IPEndPoint
在其构造函数中采用的内容(请参阅IPEndPoint(地址,端口)
)。看起来您正在那里传递本地和远程地址。编辑:
如果所有端口均不起作用,则可能是 IP 地址错误。既然您提到“升级” - 看看发生了什么变化 - 地址仍然相同吗?
ipconfig
- 提示,提示。bind()
... binds a socket to local IP address and port. That's whatIPEndPoint
takes in its constructor (seeIPEndPoint(address, port)
). Looks like you are passing local and remote addresses there instead.Edit:
If none of the ports work then it's probably the IP address that is wrong. Since you mention an "upgrade" - see what changed - is the address still the same?
ipconfig
- hint, hint.