Winsock 无法连接到本地 IP 地址
我以类似于服务器的形式使用了以下代码,
WskServer(0).Close
LocalIP = WskServer(0).LocalIP
WskServer(0).LocalPort = DEFAULT_TCP_PORT
WskServer(0).Protocol = sckTCPProtocol
txtStatus.Text = "Starting server"
Call WskServer(0).Bind(DEFAULT_TCP_PORT, LocalIP)
WskServer(0).Listen
当我执行上述代码时,我收到以下错误
“本地计算机上的地址不可用”。
如果我将行更改
Call WskServer(0).Bind(DEFAULT_TCP_PORT, LocalIP)
为
Call WskServer(0).Bind(DEFAULT_TCP_PORT, "127.0.0.1") this is working
代码有什么问题?,任何人都可以提供修复
更新
我刚刚删除了 Call WskServer(0).Bind(DEFAULT_TCP_PORT, LocalIP) 行,现在服务器正常工作。这种方式正确与否
I have used the following code in a form that acts like a server,
WskServer(0).Close
LocalIP = WskServer(0).LocalIP
WskServer(0).LocalPort = DEFAULT_TCP_PORT
WskServer(0).Protocol = sckTCPProtocol
txtStatus.Text = "Starting server"
Call WskServer(0).Bind(DEFAULT_TCP_PORT, LocalIP)
WskServer(0).Listen
when i execute above code,i received the following error
"Address is not available from the local machine" .
If i changed the line
Call WskServer(0).Bind(DEFAULT_TCP_PORT, LocalIP)
to
Call WskServer(0).Bind(DEFAULT_TCP_PORT, "127.0.0.1") this is working
What's wrong with the code?, can anybody give the fix
Update
I just removed the line Call WskServer(0).Bind(DEFAULT_TCP_PORT, LocalIP) now server working properly. this way is correct or not
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查 system32 目录中的 etc.host 文件中的 localhost 是否映射到 127.0.0.1
check whether in etc.host file in system32 directory the localhost is mapped to 127.0.0.1