Socket.bind() returns “The requested address is not valid in its context.” on Win7

社会主义新天地 提交于 2019-12-07 01:34:18

问题


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.


回答1:


bind() ... binds a socket to local IP address and port. That's what IPEndPoint takes in its constructor (see IPEndPoint(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.



来源:https://stackoverflow.com/questions/4146885/socket-bind-returns-the-requested-address-is-not-valid-in-its-context-on-wi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!